@authhero/proxy 0.8.1 → 0.8.3
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 +253 -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({
|
|
@@ -2386,6 +2476,7 @@ e.array(Pn), e.object({
|
|
|
2386
2476
|
"sessions",
|
|
2387
2477
|
"logouts",
|
|
2388
2478
|
"password-changes",
|
|
2479
|
+
"password-migrations",
|
|
2389
2480
|
"mfa",
|
|
2390
2481
|
"email-verifications",
|
|
2391
2482
|
"codes-sent"
|
|
@@ -2406,22 +2497,22 @@ e.array(Pn), e.object({
|
|
|
2406
2497
|
"passwordless",
|
|
2407
2498
|
"enterprise"
|
|
2408
2499
|
]);
|
|
2409
|
-
var
|
|
2500
|
+
var Vn = e.object({
|
|
2410
2501
|
name: e.string(),
|
|
2411
2502
|
type: e.string()
|
|
2412
|
-
}),
|
|
2503
|
+
}), Hn = e.object({
|
|
2413
2504
|
elapsed: e.number(),
|
|
2414
2505
|
rows_read: e.number().optional(),
|
|
2415
2506
|
bytes_read: e.number().optional()
|
|
2416
2507
|
});
|
|
2417
2508
|
e.object({
|
|
2418
|
-
meta: e.array(
|
|
2509
|
+
meta: e.array(Vn),
|
|
2419
2510
|
data: e.array(e.record(e.string(), e.any())),
|
|
2420
2511
|
rows: e.number(),
|
|
2421
2512
|
rows_before_limit_at_least: e.number().optional(),
|
|
2422
|
-
statistics:
|
|
2513
|
+
statistics: Hn.optional()
|
|
2423
2514
|
});
|
|
2424
|
-
var
|
|
2515
|
+
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
2516
|
type: "object",
|
|
2426
2517
|
additionalProperties: {
|
|
2427
2518
|
type: "object",
|
|
@@ -2429,11 +2520,11 @@ var Ln = e.enum(/* @__PURE__ */ "login.login-id.login-password.signup.signup-id.
|
|
|
2429
2520
|
}
|
|
2430
2521
|
});
|
|
2431
2522
|
e.object({
|
|
2432
|
-
prompt:
|
|
2523
|
+
prompt: Un,
|
|
2433
2524
|
language: e.string(),
|
|
2434
|
-
custom_text:
|
|
2525
|
+
custom_text: Wn
|
|
2435
2526
|
});
|
|
2436
|
-
var
|
|
2527
|
+
var Gn = e.enum([
|
|
2437
2528
|
"phone",
|
|
2438
2529
|
"totp",
|
|
2439
2530
|
"email",
|
|
@@ -2443,7 +2534,7 @@ var zn = e.enum([
|
|
|
2443
2534
|
"passkey"
|
|
2444
2535
|
]), M = e.object({
|
|
2445
2536
|
user_id: e.string(),
|
|
2446
|
-
type:
|
|
2537
|
+
type: Gn,
|
|
2447
2538
|
phone_number: e.string().optional(),
|
|
2448
2539
|
totp_secret: e.string().optional(),
|
|
2449
2540
|
credential_id: e.string().optional(),
|
|
@@ -2488,12 +2579,12 @@ M.superRefine(N), M.extend({
|
|
|
2488
2579
|
});
|
|
2489
2580
|
//#endregion
|
|
2490
2581
|
//#region src/data-plane/cache.ts
|
|
2491
|
-
var
|
|
2582
|
+
var Kn = 1e4;
|
|
2492
2583
|
function P(e, t, n) {
|
|
2493
2584
|
let r = typeof t == "number" ? {
|
|
2494
2585
|
freshTtlMs: t,
|
|
2495
2586
|
maxEntries: n
|
|
2496
|
-
} : t, i = r.freshTtlMs, a = r.staleTtlMs ?? 0, o = r.staleIfErrorTtlMs ?? 0, s = r.negativeTtlMs ?? i, c = r.maxEntries ??
|
|
2587
|
+
} : 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
2588
|
function d(e) {
|
|
2498
2589
|
for (let [t, n] of u) n.stale_if_error_until <= e && n.stale_until <= e && !n.refreshing && u.delete(t);
|
|
2499
2590
|
for (; u.size >= c;) {
|
|
@@ -2576,27 +2667,27 @@ function I(e) {
|
|
|
2576
2667
|
//#endregion
|
|
2577
2668
|
//#region src/data-plane/handlers/util.ts
|
|
2578
2669
|
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
|
|
2670
|
+
function qn(e, t) {
|
|
2580
2671
|
e.set(L, t);
|
|
2581
2672
|
}
|
|
2582
2673
|
function H(e) {
|
|
2583
2674
|
return e.get(L) ?? e.req.raw;
|
|
2584
2675
|
}
|
|
2585
|
-
function
|
|
2676
|
+
function Jn(e, t) {
|
|
2586
2677
|
e.set(R, t.tenant_id), e.set(z, t.custom_domain_id), e.set(B, t.domain);
|
|
2587
2678
|
}
|
|
2588
|
-
function
|
|
2679
|
+
function Yn(e) {
|
|
2589
2680
|
return e.get(R);
|
|
2590
2681
|
}
|
|
2591
|
-
function
|
|
2682
|
+
function Xn(e) {
|
|
2592
2683
|
return e.get(z);
|
|
2593
2684
|
}
|
|
2594
|
-
function
|
|
2685
|
+
function Zn(e) {
|
|
2595
2686
|
return e.get(B);
|
|
2596
2687
|
}
|
|
2597
2688
|
function U(e, t) {
|
|
2598
2689
|
let n = H(e), r = new Headers(n.headers);
|
|
2599
|
-
t(r),
|
|
2690
|
+
t(r), qn(e, new Request(n, { headers: r }));
|
|
2600
2691
|
}
|
|
2601
2692
|
function W(e) {
|
|
2602
2693
|
let t = e.res;
|
|
@@ -2613,7 +2704,7 @@ function W(e) {
|
|
|
2613
2704
|
}
|
|
2614
2705
|
//#endregion
|
|
2615
2706
|
//#region src/data-plane/handlers/cors.ts
|
|
2616
|
-
var
|
|
2707
|
+
var Qn = e.object({
|
|
2617
2708
|
origins: e.array(e.string()).optional(),
|
|
2618
2709
|
allow_credentials: e.boolean().optional(),
|
|
2619
2710
|
allow_headers: e.array(e.string()).optional(),
|
|
@@ -2625,9 +2716,9 @@ function G(e, t) {
|
|
|
2625
2716
|
let n = new Headers(), r = e.origins ?? ["*"], i = r.includes("*");
|
|
2626
2717
|
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
2718
|
}
|
|
2628
|
-
var
|
|
2719
|
+
var $n = I({
|
|
2629
2720
|
type: "cors",
|
|
2630
|
-
optionsSchema:
|
|
2721
|
+
optionsSchema: Qn,
|
|
2631
2722
|
build(e) {
|
|
2632
2723
|
return async (t, n) => {
|
|
2633
2724
|
let r = t.req.header("origin") ?? null;
|
|
@@ -2645,20 +2736,20 @@ var qn = I({
|
|
|
2645
2736
|
});
|
|
2646
2737
|
};
|
|
2647
2738
|
}
|
|
2648
|
-
}),
|
|
2739
|
+
}), er = e.object({
|
|
2649
2740
|
username: e.string(),
|
|
2650
2741
|
password: e.string(),
|
|
2651
2742
|
realm: e.string().optional()
|
|
2652
2743
|
});
|
|
2653
|
-
function
|
|
2744
|
+
function tr(e, t) {
|
|
2654
2745
|
let n = `${e}:${t}`;
|
|
2655
2746
|
return typeof btoa == "function" ? btoa(n) : Buffer.from(n, "utf-8").toString("base64");
|
|
2656
2747
|
}
|
|
2657
|
-
var
|
|
2748
|
+
var nr = I({
|
|
2658
2749
|
type: "basic_auth",
|
|
2659
|
-
optionsSchema:
|
|
2750
|
+
optionsSchema: er,
|
|
2660
2751
|
build(e) {
|
|
2661
|
-
let t =
|
|
2752
|
+
let t = tr(e.username, e.password), n = (e.realm ?? "Restricted").replace(/["\\\r\n]/g, "");
|
|
2662
2753
|
return async (e, r) => {
|
|
2663
2754
|
let i = e.req.header("authorization");
|
|
2664
2755
|
if (i) {
|
|
@@ -2674,7 +2765,7 @@ var Xn = I({
|
|
|
2674
2765
|
});
|
|
2675
2766
|
};
|
|
2676
2767
|
}
|
|
2677
|
-
}),
|
|
2768
|
+
}), rr = I({
|
|
2678
2769
|
type: "headers",
|
|
2679
2770
|
optionsSchema: e.object({
|
|
2680
2771
|
request: e.record(e.string(), e.string()).optional(),
|
|
@@ -2689,7 +2780,7 @@ var Xn = I({
|
|
|
2689
2780
|
}), 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
2781
|
};
|
|
2691
2782
|
}
|
|
2692
|
-
}),
|
|
2783
|
+
}), ir = I({
|
|
2693
2784
|
type: "cache",
|
|
2694
2785
|
optionsSchema: e.object({ ttl_seconds: e.number().int().positive() }),
|
|
2695
2786
|
build(e) {
|
|
@@ -2700,7 +2791,7 @@ var Xn = I({
|
|
|
2700
2791
|
}
|
|
2701
2792
|
};
|
|
2702
2793
|
}
|
|
2703
|
-
}),
|
|
2794
|
+
}), ar = I({
|
|
2704
2795
|
type: "forwarded_headers",
|
|
2705
2796
|
optionsSchema: e.object({
|
|
2706
2797
|
client_ip_header: e.string().default("cf-connecting-ip"),
|
|
@@ -2717,33 +2808,33 @@ var Xn = I({
|
|
|
2717
2808
|
}), await n();
|
|
2718
2809
|
};
|
|
2719
2810
|
}
|
|
2720
|
-
}),
|
|
2721
|
-
function
|
|
2811
|
+
}), or = e.object({ upstream_host: e.string().optional() });
|
|
2812
|
+
function sr(e) {
|
|
2722
2813
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
2723
2814
|
}
|
|
2724
|
-
function
|
|
2815
|
+
function cr(e) {
|
|
2725
2816
|
if (typeof e.getSetCookie == "function") return e.getSetCookie();
|
|
2726
2817
|
let t = [];
|
|
2727
2818
|
return e.forEach((e, n) => {
|
|
2728
2819
|
n.toLowerCase() === "set-cookie" && t.push(e);
|
|
2729
2820
|
}), t;
|
|
2730
2821
|
}
|
|
2731
|
-
var
|
|
2822
|
+
var lr = I({
|
|
2732
2823
|
type: "rewrite_cookies",
|
|
2733
|
-
optionsSchema:
|
|
2824
|
+
optionsSchema: or,
|
|
2734
2825
|
build(e) {
|
|
2735
2826
|
return async (t, n) => {
|
|
2736
2827
|
await n();
|
|
2737
2828
|
let r = new URL(t.req.url).hostname, i = e.upstream_host ?? t.get("__proxy_upstream_host__");
|
|
2738
2829
|
if (!i) return;
|
|
2739
|
-
let a =
|
|
2830
|
+
let a = cr(t.res.headers);
|
|
2740
2831
|
if (a.length === 0) return;
|
|
2741
|
-
let o =
|
|
2832
|
+
let o = sr(i), s = RegExp(`(?:^|;\\s*)Domain=\\.?${o}(?=;|$)`, "i");
|
|
2742
2833
|
W(t), t.res.headers.delete("set-cookie");
|
|
2743
2834
|
for (let e of a) t.res.headers.append("set-cookie", e.replace(s, `Domain=${r}`));
|
|
2744
2835
|
};
|
|
2745
2836
|
}
|
|
2746
|
-
}),
|
|
2837
|
+
}), ur = I({
|
|
2747
2838
|
type: "rewrite_location",
|
|
2748
2839
|
optionsSchema: e.object({ upstream_origin: e.string().optional() }),
|
|
2749
2840
|
build(e) {
|
|
@@ -2766,14 +2857,14 @@ var rr = I({
|
|
|
2766
2857
|
W(t), t.res.headers.set("location", c);
|
|
2767
2858
|
};
|
|
2768
2859
|
}
|
|
2769
|
-
}),
|
|
2860
|
+
}), dr = class extends Error {
|
|
2770
2861
|
ms;
|
|
2771
2862
|
constructor(e, t) {
|
|
2772
2863
|
super(`${t ?? "Operation"} timed out after ${e}ms`), this.name = "TimeoutError", this.ms = e;
|
|
2773
2864
|
}
|
|
2774
2865
|
};
|
|
2775
2866
|
function K(e) {
|
|
2776
|
-
return e instanceof
|
|
2867
|
+
return e instanceof dr ? !0 : e instanceof Error ? e.name === "AbortError" || e.name === "TimeoutError" : !1;
|
|
2777
2868
|
}
|
|
2778
2869
|
function q(e, t) {
|
|
2779
2870
|
let n = new AbortController(), r = setTimeout(() => n.abort(), e);
|
|
@@ -2781,7 +2872,7 @@ function q(e, t) {
|
|
|
2781
2872
|
}
|
|
2782
2873
|
function J(e, t, n) {
|
|
2783
2874
|
let r, i = new Promise((e, i) => {
|
|
2784
|
-
r = setTimeout(() => i(new
|
|
2875
|
+
r = setTimeout(() => i(new dr(t, n)), t);
|
|
2785
2876
|
});
|
|
2786
2877
|
return Promise.race([e, i]).finally(() => {
|
|
2787
2878
|
r && clearTimeout(r);
|
|
@@ -2789,7 +2880,7 @@ function J(e, t, n) {
|
|
|
2789
2880
|
}
|
|
2790
2881
|
//#endregion
|
|
2791
2882
|
//#region src/data-plane/handlers/http.ts
|
|
2792
|
-
var
|
|
2883
|
+
var fr = /* @__PURE__ */ new Set([
|
|
2793
2884
|
"connection",
|
|
2794
2885
|
"keep-alive",
|
|
2795
2886
|
"proxy-authenticate",
|
|
@@ -2798,24 +2889,24 @@ var or = /* @__PURE__ */ new Set([
|
|
|
2798
2889
|
"trailers",
|
|
2799
2890
|
"transfer-encoding",
|
|
2800
2891
|
"upgrade"
|
|
2801
|
-
]),
|
|
2892
|
+
]), pr = 3e4, mr = e.object({
|
|
2802
2893
|
upstream_url: e.string(),
|
|
2803
2894
|
preserve_host: e.boolean().default(!1),
|
|
2804
2895
|
timeout_ms: e.number().int().positive().optional()
|
|
2805
2896
|
});
|
|
2806
|
-
function
|
|
2897
|
+
function hr(e, t) {
|
|
2807
2898
|
return e === "" || e === "/" ? t : `${e.endsWith("/") ? e.slice(0, -1) : e}${t.startsWith("/") ? t : `/${t}`}`;
|
|
2808
2899
|
}
|
|
2809
|
-
function
|
|
2900
|
+
function gr(e) {
|
|
2810
2901
|
return e !== "GET" && e !== "HEAD";
|
|
2811
2902
|
}
|
|
2812
|
-
function
|
|
2903
|
+
function _r(e, t) {
|
|
2813
2904
|
let n = new URL(t.url), r = new URL(e.upstream_url);
|
|
2814
|
-
r.pathname =
|
|
2905
|
+
r.pathname = hr(r.pathname, n.pathname), r.search = n.search;
|
|
2815
2906
|
let i = new Headers(t.headers);
|
|
2816
|
-
for (let e of
|
|
2907
|
+
for (let e of fr) i.delete(e);
|
|
2817
2908
|
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 =
|
|
2909
|
+
let a = gr(t.method) ? t.body : void 0, o = {
|
|
2819
2910
|
method: t.method,
|
|
2820
2911
|
headers: i,
|
|
2821
2912
|
body: a,
|
|
@@ -2826,13 +2917,13 @@ function dr(e, t) {
|
|
|
2826
2917
|
init: o
|
|
2827
2918
|
};
|
|
2828
2919
|
}
|
|
2829
|
-
var
|
|
2920
|
+
var vr = I({
|
|
2830
2921
|
type: "http",
|
|
2831
|
-
optionsSchema:
|
|
2922
|
+
optionsSchema: mr,
|
|
2832
2923
|
build(e) {
|
|
2833
|
-
let t = e.timeout_ms ??
|
|
2924
|
+
let t = e.timeout_ms ?? pr;
|
|
2834
2925
|
return async (n) => {
|
|
2835
|
-
let { target: r, init: i } =
|
|
2926
|
+
let { target: r, init: i } = _r(e, H(n));
|
|
2836
2927
|
n.set("__proxy_upstream_host__", r.hostname), n.set("__proxy_upstream_origin__", `${r.protocol}//${r.host}`);
|
|
2837
2928
|
try {
|
|
2838
2929
|
return await q(t, (e) => fetch(r.toString(), {
|
|
@@ -2844,24 +2935,24 @@ var fr = I({
|
|
|
2844
2935
|
}
|
|
2845
2936
|
};
|
|
2846
2937
|
}
|
|
2847
|
-
}),
|
|
2938
|
+
}), yr = 3e4, br = e.object({
|
|
2848
2939
|
binding: e.string(),
|
|
2849
2940
|
upstream_url: e.string().optional(),
|
|
2850
2941
|
preserve_host: e.boolean().default(!0),
|
|
2851
2942
|
timeout_ms: e.number().int().positive().optional()
|
|
2852
2943
|
});
|
|
2853
|
-
function
|
|
2944
|
+
function xr(e) {
|
|
2854
2945
|
return typeof e == "object" && !!e && typeof e.fetch == "function";
|
|
2855
2946
|
}
|
|
2856
|
-
var
|
|
2947
|
+
var Sr = I({
|
|
2857
2948
|
type: "service_binding",
|
|
2858
|
-
optionsSchema:
|
|
2949
|
+
optionsSchema: br,
|
|
2859
2950
|
build(e, t) {
|
|
2860
2951
|
let n = t.bindings[e.binding];
|
|
2861
|
-
if (!
|
|
2862
|
-
let r = e.upstream_url ?? `https://${e.binding}.binding.invalid/`, i = e.timeout_ms ??
|
|
2952
|
+
if (!xr(n)) throw Error(`Service binding "${e.binding}" is not configured or is not a Fetcher`);
|
|
2953
|
+
let r = e.upstream_url ?? `https://${e.binding}.binding.invalid/`, i = e.timeout_ms ?? yr;
|
|
2863
2954
|
return async (t) => {
|
|
2864
|
-
let a = H(t), { target: o, init: s } =
|
|
2955
|
+
let a = H(t), { target: o, init: s } = _r({
|
|
2865
2956
|
upstream_url: r,
|
|
2866
2957
|
preserve_host: e.preserve_host
|
|
2867
2958
|
}, a);
|
|
@@ -2876,34 +2967,34 @@ var gr = I({
|
|
|
2876
2967
|
}
|
|
2877
2968
|
};
|
|
2878
2969
|
}
|
|
2879
|
-
}),
|
|
2970
|
+
}), Cr = 3e4, wr = e.object({
|
|
2880
2971
|
binding: e.string(),
|
|
2881
2972
|
script_name: e.string(),
|
|
2882
2973
|
cpu_ms: e.number().int().positive().optional(),
|
|
2883
2974
|
subrequests: e.number().int().positive().optional(),
|
|
2884
2975
|
timeout_ms: e.number().int().positive().optional()
|
|
2885
2976
|
});
|
|
2886
|
-
function
|
|
2977
|
+
function Tr(e) {
|
|
2887
2978
|
return typeof e == "object" && !!e && typeof e.get == "function";
|
|
2888
2979
|
}
|
|
2889
2980
|
var Y = /\{(tenant_id|custom_domain_id|domain|host)\}/g;
|
|
2890
|
-
function
|
|
2981
|
+
function Er(e) {
|
|
2891
2982
|
return Y.lastIndex = 0, Y.test(e);
|
|
2892
2983
|
}
|
|
2893
|
-
var
|
|
2984
|
+
var Dr = I({
|
|
2894
2985
|
type: "dispatch_namespace",
|
|
2895
|
-
optionsSchema:
|
|
2986
|
+
optionsSchema: wr,
|
|
2896
2987
|
build(e, t) {
|
|
2897
2988
|
let n = t.bindings[e.binding];
|
|
2898
|
-
if (!
|
|
2899
|
-
let r =
|
|
2989
|
+
if (!Tr(n)) throw Error(`Dispatch namespace binding "${e.binding}" is not configured or does not expose .get()`);
|
|
2990
|
+
let r = Er(e.script_name), i = e.timeout_ms ?? Cr, a = e.cpu_ms || e.subrequests ? { limits: {
|
|
2900
2991
|
...e.cpu_ms ? { cpuMs: e.cpu_ms } : {},
|
|
2901
2992
|
...e.subrequests ? { subrequests: e.subrequests } : {}
|
|
2902
2993
|
} } : void 0;
|
|
2903
2994
|
return async (t) => {
|
|
2904
2995
|
let o = e.script_name;
|
|
2905
2996
|
if (r) {
|
|
2906
|
-
let n =
|
|
2997
|
+
let n = Yn(t), r = Xn(t), i = Zn(t), a = t.req.header("host") ?? t.req.header("x-forwarded-host") ?? "";
|
|
2907
2998
|
if (o = o.replace(Y, (e, t) => {
|
|
2908
2999
|
switch (t) {
|
|
2909
3000
|
case "tenant_id": return n ?? "";
|
|
@@ -2926,7 +3017,7 @@ var xr = I({
|
|
|
2926
3017
|
}
|
|
2927
3018
|
};
|
|
2928
3019
|
}
|
|
2929
|
-
}),
|
|
3020
|
+
}), Or = I({
|
|
2930
3021
|
type: "redirect",
|
|
2931
3022
|
optionsSchema: e.object({
|
|
2932
3023
|
upstream_url: e.string().refine((e) => {
|
|
@@ -2955,7 +3046,7 @@ var xr = I({
|
|
|
2955
3046
|
});
|
|
2956
3047
|
};
|
|
2957
3048
|
}
|
|
2958
|
-
}),
|
|
3049
|
+
}), kr = I({
|
|
2959
3050
|
type: "static",
|
|
2960
3051
|
optionsSchema: e.object({
|
|
2961
3052
|
status: e.number().int().default(200),
|
|
@@ -2975,15 +3066,15 @@ var xr = I({
|
|
|
2975
3066
|
});
|
|
2976
3067
|
//#endregion
|
|
2977
3068
|
//#region src/data-plane/handlers/index.ts
|
|
2978
|
-
function
|
|
2979
|
-
e.add(
|
|
3069
|
+
function Ar(e) {
|
|
3070
|
+
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
3071
|
}
|
|
2981
3072
|
//#endregion
|
|
2982
3073
|
//#region src/data-plane/matcher.ts
|
|
2983
3074
|
function X(e) {
|
|
2984
3075
|
return [...e].sort((e, t) => e.priority === t.priority ? e.created_at.localeCompare(t.created_at) : e.priority - t.priority);
|
|
2985
3076
|
}
|
|
2986
|
-
function
|
|
3077
|
+
function jr(e, t) {
|
|
2987
3078
|
let n = e.toLowerCase(), r = t.toLowerCase();
|
|
2988
3079
|
if (n === r) return !0;
|
|
2989
3080
|
if (n.startsWith("*.")) {
|
|
@@ -2992,13 +3083,16 @@ function Tr(e, t) {
|
|
|
2992
3083
|
}
|
|
2993
3084
|
return !1;
|
|
2994
3085
|
}
|
|
2995
|
-
function
|
|
2996
|
-
return !e || e.length === 0 ? !0 : e.some((e) =>
|
|
3086
|
+
function Mr(e, t) {
|
|
3087
|
+
return !e || e.length === 0 ? !0 : e.some((e) => jr(e, t));
|
|
2997
3088
|
}
|
|
2998
|
-
function
|
|
3089
|
+
function Nr(e) {
|
|
2999
3090
|
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
3091
|
return async (e, i) => {
|
|
3001
|
-
if (r
|
|
3092
|
+
if (r) {
|
|
3093
|
+
let t = e.req.header("host") ?? "";
|
|
3094
|
+
if (!Mr(r, t)) return new Response("No matching route", { status: 404 });
|
|
3095
|
+
}
|
|
3002
3096
|
for (let [n, r] of t) {
|
|
3003
3097
|
let t = e.req.header(n);
|
|
3004
3098
|
if (t === void 0 || !r.test(t)) return new Response("No matching route", { status: 404 });
|
|
@@ -3015,7 +3109,7 @@ function Dr(e) {
|
|
|
3015
3109
|
}
|
|
3016
3110
|
//#endregion
|
|
3017
3111
|
//#region src/data-plane/compile.ts
|
|
3018
|
-
var
|
|
3112
|
+
var Pr = [
|
|
3019
3113
|
"GET",
|
|
3020
3114
|
"POST",
|
|
3021
3115
|
"PUT",
|
|
@@ -3027,34 +3121,34 @@ var Or = [
|
|
|
3027
3121
|
function Z(e, n, r, i) {
|
|
3028
3122
|
let a = new t();
|
|
3029
3123
|
r && a.use("*", async (e, t) => {
|
|
3030
|
-
|
|
3124
|
+
Jn(e, r), await t();
|
|
3031
3125
|
});
|
|
3032
3126
|
let o = X(e);
|
|
3033
3127
|
for (let e of o) {
|
|
3034
3128
|
let t = [];
|
|
3035
|
-
t.push(
|
|
3129
|
+
t.push(Nr(e.match));
|
|
3036
3130
|
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()) :
|
|
3131
|
+
let r = e.match.methods?.length ? e.match.methods.map((e) => e.toUpperCase()) : Pr, i = e.match.path || "/*";
|
|
3038
3132
|
a.on(r, [i], ...t);
|
|
3039
3133
|
}
|
|
3040
|
-
return i && i.length > 0 ? a.on(
|
|
3134
|
+
return i && i.length > 0 ? a.on(Pr, ["*"], ...i) : a.all("*", (e) => e.text("No matching route", 404)), a.onError((e, t) => {
|
|
3041
3135
|
let n = K(e);
|
|
3042
3136
|
return t.text(n ? "Upstream timeout" : "Bad gateway", n ? 504 : 502, { "x-authhero-proxy-error": n ? "handler_timeout" : "handler_failed" });
|
|
3043
3137
|
}), a;
|
|
3044
3138
|
}
|
|
3045
3139
|
//#endregion
|
|
3046
3140
|
//#region src/data-plane/router.ts
|
|
3047
|
-
var
|
|
3048
|
-
function
|
|
3141
|
+
var Fr = 1e4;
|
|
3142
|
+
function Ir(e) {
|
|
3049
3143
|
return e.resolver ? e.resolver : e.cache ? P(e.data, e.cache) : P(e.data, e.cacheTtlMs ?? 3e4);
|
|
3050
3144
|
}
|
|
3051
|
-
function
|
|
3145
|
+
function Lr(e) {
|
|
3052
3146
|
if (e.registry) return e.registry;
|
|
3053
3147
|
let t = new F(e.bindings ?? {});
|
|
3054
|
-
return
|
|
3148
|
+
return Ar(t), t;
|
|
3055
3149
|
}
|
|
3056
3150
|
function Q(e) {
|
|
3057
|
-
let t =
|
|
3151
|
+
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
3152
|
return async (e) => {
|
|
3059
3153
|
let s = e.req.header("host") ?? e.req.header("x-forwarded-host");
|
|
3060
3154
|
if (!s) return e.text("Missing host", 400);
|
|
@@ -3072,13 +3166,13 @@ function Q(e) {
|
|
|
3072
3166
|
}
|
|
3073
3167
|
};
|
|
3074
3168
|
}
|
|
3075
|
-
function
|
|
3169
|
+
function Rr(e) {
|
|
3076
3170
|
let n = new t();
|
|
3077
3171
|
return n.all("*", Q(e)), n;
|
|
3078
3172
|
}
|
|
3079
3173
|
//#endregion
|
|
3080
3174
|
//#region src/app.ts
|
|
3081
|
-
function
|
|
3175
|
+
function zr(e) {
|
|
3082
3176
|
let n = new t();
|
|
3083
3177
|
return n.all("*", Q({
|
|
3084
3178
|
data: e.data,
|
|
@@ -3096,17 +3190,17 @@ function Nr(e) {
|
|
|
3096
3190
|
}
|
|
3097
3191
|
//#endregion
|
|
3098
3192
|
//#region src/data-plane/cache-api-cache.ts
|
|
3099
|
-
var
|
|
3100
|
-
function
|
|
3193
|
+
var Br = 1e3, Vr = 1e3;
|
|
3194
|
+
function Hr(e, t) {
|
|
3101
3195
|
return new Request(`https://proxy-cache.internal/${encodeURIComponent(e)}/hosts/${encodeURIComponent(t.toLowerCase())}`, { method: "GET" });
|
|
3102
3196
|
}
|
|
3103
|
-
function
|
|
3197
|
+
function Ur() {
|
|
3104
3198
|
return globalThis.caches?.default;
|
|
3105
3199
|
}
|
|
3106
|
-
function
|
|
3107
|
-
let t = e.cache ??
|
|
3200
|
+
function Wr(e) {
|
|
3201
|
+
let t = e.cache ?? Ur();
|
|
3108
3202
|
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 ??
|
|
3203
|
+
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
3204
|
async function l(e) {
|
|
3111
3205
|
try {
|
|
3112
3206
|
return await J(Promise.resolve(n.match(e)), s, "cache.match");
|
|
@@ -3115,7 +3209,7 @@ function Rr(e) {
|
|
|
3115
3209
|
}
|
|
3116
3210
|
}
|
|
3117
3211
|
return { async resolveHost(t) {
|
|
3118
|
-
let s =
|
|
3212
|
+
let s = Hr(r, t), u = await l(s);
|
|
3119
3213
|
if (u) try {
|
|
3120
3214
|
return (await u.json()).value;
|
|
3121
3215
|
} catch {}
|
|
@@ -3126,14 +3220,14 @@ function Rr(e) {
|
|
|
3126
3220
|
return o ? o(m) : await m, d;
|
|
3127
3221
|
} };
|
|
3128
3222
|
}
|
|
3129
|
-
function
|
|
3130
|
-
return
|
|
3223
|
+
function Gr(e, t) {
|
|
3224
|
+
return Hr(e, t);
|
|
3131
3225
|
}
|
|
3132
3226
|
//#endregion
|
|
3133
3227
|
//#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 =
|
|
3228
|
+
var Kr = 1e3, qr = 1e3;
|
|
3229
|
+
function Jr(e) {
|
|
3230
|
+
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
3231
|
function f(e) {
|
|
3138
3232
|
return `${s}:${e.toLowerCase()}`;
|
|
3139
3233
|
}
|
|
@@ -3186,7 +3280,7 @@ function Hr(e) {
|
|
|
3186
3280
|
}
|
|
3187
3281
|
} };
|
|
3188
3282
|
}
|
|
3189
|
-
function
|
|
3283
|
+
function Yr(e, t) {
|
|
3190
3284
|
return `${e}:${t.toLowerCase()}`;
|
|
3191
3285
|
}
|
|
3192
3286
|
//#endregion
|
|
@@ -3194,7 +3288,7 @@ function Ur(e, t) {
|
|
|
3194
3288
|
function $() {
|
|
3195
3289
|
throw Error("Static proxy adapter is read-only; configure routes at init time");
|
|
3196
3290
|
}
|
|
3197
|
-
function
|
|
3291
|
+
function Xr(e, t, n, r, i, a) {
|
|
3198
3292
|
return {
|
|
3199
3293
|
id: e.id ?? `${n}:${t}`,
|
|
3200
3294
|
tenant_id: r,
|
|
@@ -3209,10 +3303,10 @@ function Wr(e, t, n, r, i, a) {
|
|
|
3209
3303
|
updated_at: e.updated_at ?? a
|
|
3210
3304
|
};
|
|
3211
3305
|
}
|
|
3212
|
-
function
|
|
3306
|
+
function Zr(e) {
|
|
3213
3307
|
let t = (/* @__PURE__ */ new Date()).toISOString(), n = e.defaultTenantId ?? "static", r = /* @__PURE__ */ new Map();
|
|
3214
3308
|
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) =>
|
|
3309
|
+
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
3310
|
r.set(e, {
|
|
3217
3311
|
tenant_id: s,
|
|
3218
3312
|
custom_domain_id: c,
|
|
@@ -3256,7 +3350,7 @@ function Gr(e) {
|
|
|
3256
3350
|
}
|
|
3257
3351
|
};
|
|
3258
3352
|
}
|
|
3259
|
-
function
|
|
3353
|
+
function Qr(e, t = {}) {
|
|
3260
3354
|
return {
|
|
3261
3355
|
priority: t.priority,
|
|
3262
3356
|
match: { path: t.path ?? "/*" },
|
|
@@ -3271,10 +3365,10 @@ function Kr(e, t = {}) {
|
|
|
3271
3365
|
}
|
|
3272
3366
|
//#endregion
|
|
3273
3367
|
//#region src/constants.ts
|
|
3274
|
-
var
|
|
3368
|
+
var $r = "proxy:resolve_host";
|
|
3275
3369
|
//#endregion
|
|
3276
3370
|
//#region src/http-adapter/index.ts
|
|
3277
|
-
function
|
|
3371
|
+
function ei() {
|
|
3278
3372
|
let e = () => {
|
|
3279
3373
|
throw Error("HTTP proxy adapter does not expose write access to proxy_routes; mutate via the control-plane management API");
|
|
3280
3374
|
};
|
|
@@ -3296,7 +3390,7 @@ function Jr() {
|
|
|
3296
3390
|
}
|
|
3297
3391
|
};
|
|
3298
3392
|
}
|
|
3299
|
-
function
|
|
3393
|
+
function ti(e) {
|
|
3300
3394
|
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
3395
|
function c(e) {
|
|
3302
3396
|
let t = new AbortController(), n = setTimeout(() => t.abort(), s);
|
|
@@ -3329,7 +3423,7 @@ function Yr(e) {
|
|
|
3329
3423
|
}), u);
|
|
3330
3424
|
}
|
|
3331
3425
|
return {
|
|
3332
|
-
proxyRoutes:
|
|
3426
|
+
proxyRoutes: ei(),
|
|
3333
3427
|
async resolveHost(e) {
|
|
3334
3428
|
let i = await f(), a = `${n}${r}${encodeURIComponent(e.toLowerCase())}`, o = await c((e) => t(a, {
|
|
3335
3429
|
headers: { authorization: `Bearer ${i}` },
|
|
@@ -3343,11 +3437,11 @@ function Yr(e) {
|
|
|
3343
3437
|
}
|
|
3344
3438
|
//#endregion
|
|
3345
3439
|
//#region src/kv-adapter/index.ts
|
|
3346
|
-
var
|
|
3347
|
-
function
|
|
3440
|
+
var ni = "authhero-proxy-host:";
|
|
3441
|
+
function ri(e, t) {
|
|
3348
3442
|
return `${e}${t.toLowerCase()}`;
|
|
3349
3443
|
}
|
|
3350
|
-
function
|
|
3444
|
+
function ii() {
|
|
3351
3445
|
let e = () => {
|
|
3352
3446
|
throw Error("KV proxy adapter does not expose write access to proxy_routes; mutate via the control-plane management API");
|
|
3353
3447
|
};
|
|
@@ -3369,15 +3463,15 @@ function Qr() {
|
|
|
3369
3463
|
}
|
|
3370
3464
|
};
|
|
3371
3465
|
}
|
|
3372
|
-
function
|
|
3373
|
-
let { kv: t, keyPrefix: n =
|
|
3466
|
+
function ai(e) {
|
|
3467
|
+
let { kv: t, keyPrefix: n = ni, timeoutMs: r } = e;
|
|
3374
3468
|
return {
|
|
3375
|
-
proxyRoutes:
|
|
3469
|
+
proxyRoutes: ii(),
|
|
3376
3470
|
async resolveHost(e) {
|
|
3377
|
-
let i =
|
|
3471
|
+
let i = ri(n, e), a = t.get(i, "json");
|
|
3378
3472
|
return (r && r > 0 ? await J(a, r, "kv.get") : await a) ?? null;
|
|
3379
3473
|
}
|
|
3380
3474
|
};
|
|
3381
3475
|
}
|
|
3382
3476
|
//#endregion
|
|
3383
|
-
export {
|
|
3477
|
+
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 };
|