@authhero/proxy 0.8.0 → 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 +260 -160
- 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,26 +2250,33 @@ 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" }),
|
|
2180
2270
|
scope: e.array(e.string()).default([]).openapi({ description: "The list of OAuth scopes the user has consented to" })
|
|
2181
|
-
}).extend({ id: e.string() })
|
|
2182
|
-
|
|
2271
|
+
}).extend({ id: e.string() }), e.object({
|
|
2272
|
+
user_id: e.string(),
|
|
2273
|
+
last_login: e.string().optional(),
|
|
2274
|
+
last_ip: e.string().optional(),
|
|
2275
|
+
login_count: e.number().default(0),
|
|
2276
|
+
failed_logins: e.array(e.string()).optional(),
|
|
2277
|
+
last_password_reset: e.string().optional()
|
|
2278
|
+
});
|
|
2279
|
+
var Nn = e.object({
|
|
2183
2280
|
user_id: e.string(),
|
|
2184
2281
|
resource_server_identifier: e.string(),
|
|
2185
2282
|
permission_name: e.string(),
|
|
@@ -2188,8 +2285,8 @@ var Dn = e.object({
|
|
|
2188
2285
|
tenant_id: e.string(),
|
|
2189
2286
|
created_at: e.string().optional()
|
|
2190
2287
|
});
|
|
2191
|
-
e.array(
|
|
2192
|
-
var
|
|
2288
|
+
e.array(Nn);
|
|
2289
|
+
var Pn = e.object({
|
|
2193
2290
|
user_id: e.string(),
|
|
2194
2291
|
resource_server_identifier: e.string(),
|
|
2195
2292
|
resource_server_name: e.string(),
|
|
@@ -2198,8 +2295,8 @@ var On = e.object({
|
|
|
2198
2295
|
created_at: e.string().optional(),
|
|
2199
2296
|
organization_id: e.string().optional()
|
|
2200
2297
|
});
|
|
2201
|
-
e.array(
|
|
2202
|
-
var
|
|
2298
|
+
e.array(Pn);
|
|
2299
|
+
var Fn = e.object({
|
|
2203
2300
|
user_id: e.string(),
|
|
2204
2301
|
role_id: e.string(),
|
|
2205
2302
|
organization_id: e.string().optional()
|
|
@@ -2207,8 +2304,8 @@ var kn = e.object({
|
|
|
2207
2304
|
tenant_id: e.string(),
|
|
2208
2305
|
created_at: e.string().optional()
|
|
2209
2306
|
});
|
|
2210
|
-
e.array(
|
|
2211
|
-
var
|
|
2307
|
+
e.array(Fn);
|
|
2308
|
+
var In = e.object({
|
|
2212
2309
|
id: e.string().optional().openapi({ description: "The unique identifier of the role. If not provided, one will be generated." }),
|
|
2213
2310
|
name: e.string().min(1).max(50).openapi({ description: "The name of the role. Cannot include '<' or '>'" }),
|
|
2214
2311
|
description: e.string().max(255).optional().openapi({ description: "The description of the role" }),
|
|
@@ -2219,19 +2316,19 @@ var An = e.object({
|
|
|
2219
2316
|
created_at: e.string().optional(),
|
|
2220
2317
|
updated_at: e.string().optional()
|
|
2221
2318
|
});
|
|
2222
|
-
e.array(
|
|
2223
|
-
var
|
|
2319
|
+
e.array(In);
|
|
2320
|
+
var Ln = e.object({
|
|
2224
2321
|
logo_url: e.string().optional().openapi({ description: "URL of the organization's logo" }),
|
|
2225
2322
|
colors: e.object({
|
|
2226
2323
|
primary: e.string().optional().openapi({ description: "Primary color in hex format (e.g., #FF0000)" }),
|
|
2227
2324
|
page_background: e.string().optional().openapi({ description: "Page background color in hex format (e.g., #FFFFFF)" })
|
|
2228
2325
|
}).optional()
|
|
2229
|
-
}).optional(),
|
|
2326
|
+
}).optional(), Rn = e.object({
|
|
2230
2327
|
connection_id: e.string().openapi({ description: "ID of the connection" }),
|
|
2231
2328
|
assign_membership_on_login: e.boolean().default(!1).openapi({ description: "Whether to assign membership to the organization on login" }),
|
|
2232
2329
|
show_as_button: e.boolean().default(!0).openapi({ description: "Whether to show this connection as a button in the login screen" }),
|
|
2233
2330
|
is_signup_enabled: e.boolean().default(!0).openapi({ description: "Whether signup is enabled for this connection" })
|
|
2234
|
-
}),
|
|
2331
|
+
}), zn = e.object({ client_credentials: e.object({
|
|
2235
2332
|
enforce: e.boolean().default(!1).openapi({ description: "Whether to enforce token quota limits" }),
|
|
2236
2333
|
per_day: e.number().min(0).default(0).openapi({ description: "Maximum tokens per day (0 = unlimited)" }),
|
|
2237
2334
|
per_hour: e.number().min(0).default(0).openapi({ description: "Maximum tokens per hour (0 = unlimited)" })
|
|
@@ -2240,15 +2337,15 @@ e.object({
|
|
|
2240
2337
|
id: e.string().optional(),
|
|
2241
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." }),
|
|
2242
2339
|
display_name: e.string().optional().openapi({ description: "The display name of the organization" }),
|
|
2243
|
-
branding:
|
|
2340
|
+
branding: Ln,
|
|
2244
2341
|
metadata: e.record(e.string(), e.any()).default({}).optional().openapi({ description: "Custom metadata for the organization" }),
|
|
2245
|
-
enabled_connections: e.array(
|
|
2246
|
-
token_quota:
|
|
2342
|
+
enabled_connections: e.array(Rn).default([]).optional().openapi({ description: "List of enabled connections for the organization" }),
|
|
2343
|
+
token_quota: zn
|
|
2247
2344
|
}).extend(n.shape).extend({
|
|
2248
2345
|
id: e.string(),
|
|
2249
2346
|
name: e.string().min(1).openapi({ description: "The name of the organization" })
|
|
2250
2347
|
});
|
|
2251
|
-
var
|
|
2348
|
+
var Bn = e.object({
|
|
2252
2349
|
connection_id: e.string().openapi({ description: "ID of the tenant-level connection to enable for the org." }),
|
|
2253
2350
|
assign_membership_on_login: e.boolean().optional().default(!1),
|
|
2254
2351
|
show_as_button: e.boolean().optional().default(!0),
|
|
@@ -2261,7 +2358,7 @@ var Pn = e.object({
|
|
|
2261
2358
|
created_at: e.string().optional(),
|
|
2262
2359
|
updated_at: e.string().optional()
|
|
2263
2360
|
});
|
|
2264
|
-
e.array(
|
|
2361
|
+
e.array(Bn), e.object({
|
|
2265
2362
|
user_id: e.string().openapi({ description: "ID of the user" }),
|
|
2266
2363
|
organization_id: e.string().openapi({ description: "ID of the organization" })
|
|
2267
2364
|
}).extend(n.shape).extend({ id: e.string() }), e.object({
|
|
@@ -2399,22 +2496,22 @@ e.array(Pn), e.object({
|
|
|
2399
2496
|
"passwordless",
|
|
2400
2497
|
"enterprise"
|
|
2401
2498
|
]);
|
|
2402
|
-
var
|
|
2499
|
+
var Vn = e.object({
|
|
2403
2500
|
name: e.string(),
|
|
2404
2501
|
type: e.string()
|
|
2405
|
-
}),
|
|
2502
|
+
}), Hn = e.object({
|
|
2406
2503
|
elapsed: e.number(),
|
|
2407
2504
|
rows_read: e.number().optional(),
|
|
2408
2505
|
bytes_read: e.number().optional()
|
|
2409
2506
|
});
|
|
2410
2507
|
e.object({
|
|
2411
|
-
meta: e.array(
|
|
2508
|
+
meta: e.array(Vn),
|
|
2412
2509
|
data: e.array(e.record(e.string(), e.any())),
|
|
2413
2510
|
rows: e.number(),
|
|
2414
2511
|
rows_before_limit_at_least: e.number().optional(),
|
|
2415
|
-
statistics:
|
|
2512
|
+
statistics: Hn.optional()
|
|
2416
2513
|
});
|
|
2417
|
-
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({
|
|
2418
2515
|
type: "object",
|
|
2419
2516
|
additionalProperties: {
|
|
2420
2517
|
type: "object",
|
|
@@ -2422,11 +2519,11 @@ var Ln = e.enum(/* @__PURE__ */ "login.login-id.login-password.signup.signup-id.
|
|
|
2422
2519
|
}
|
|
2423
2520
|
});
|
|
2424
2521
|
e.object({
|
|
2425
|
-
prompt:
|
|
2522
|
+
prompt: Un,
|
|
2426
2523
|
language: e.string(),
|
|
2427
|
-
custom_text:
|
|
2524
|
+
custom_text: Wn
|
|
2428
2525
|
});
|
|
2429
|
-
var
|
|
2526
|
+
var Gn = e.enum([
|
|
2430
2527
|
"phone",
|
|
2431
2528
|
"totp",
|
|
2432
2529
|
"email",
|
|
@@ -2436,7 +2533,7 @@ var zn = e.enum([
|
|
|
2436
2533
|
"passkey"
|
|
2437
2534
|
]), M = e.object({
|
|
2438
2535
|
user_id: e.string(),
|
|
2439
|
-
type:
|
|
2536
|
+
type: Gn,
|
|
2440
2537
|
phone_number: e.string().optional(),
|
|
2441
2538
|
totp_secret: e.string().optional(),
|
|
2442
2539
|
credential_id: e.string().optional(),
|
|
@@ -2481,12 +2578,12 @@ M.superRefine(N), M.extend({
|
|
|
2481
2578
|
});
|
|
2482
2579
|
//#endregion
|
|
2483
2580
|
//#region src/data-plane/cache.ts
|
|
2484
|
-
var
|
|
2581
|
+
var Kn = 1e4;
|
|
2485
2582
|
function P(e, t, n) {
|
|
2486
2583
|
let r = typeof t == "number" ? {
|
|
2487
2584
|
freshTtlMs: t,
|
|
2488
2585
|
maxEntries: n
|
|
2489
|
-
} : 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();
|
|
2490
2587
|
function d(e) {
|
|
2491
2588
|
for (let [t, n] of u) n.stale_if_error_until <= e && n.stale_until <= e && !n.refreshing && u.delete(t);
|
|
2492
2589
|
for (; u.size >= c;) {
|
|
@@ -2569,27 +2666,27 @@ function I(e) {
|
|
|
2569
2666
|
//#endregion
|
|
2570
2667
|
//#region src/data-plane/handlers/util.ts
|
|
2571
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";
|
|
2572
|
-
function
|
|
2669
|
+
function qn(e, t) {
|
|
2573
2670
|
e.set(L, t);
|
|
2574
2671
|
}
|
|
2575
2672
|
function H(e) {
|
|
2576
2673
|
return e.get(L) ?? e.req.raw;
|
|
2577
2674
|
}
|
|
2578
|
-
function
|
|
2675
|
+
function Jn(e, t) {
|
|
2579
2676
|
e.set(R, t.tenant_id), e.set(z, t.custom_domain_id), e.set(B, t.domain);
|
|
2580
2677
|
}
|
|
2581
|
-
function
|
|
2678
|
+
function Yn(e) {
|
|
2582
2679
|
return e.get(R);
|
|
2583
2680
|
}
|
|
2584
|
-
function
|
|
2681
|
+
function Xn(e) {
|
|
2585
2682
|
return e.get(z);
|
|
2586
2683
|
}
|
|
2587
|
-
function
|
|
2684
|
+
function Zn(e) {
|
|
2588
2685
|
return e.get(B);
|
|
2589
2686
|
}
|
|
2590
2687
|
function U(e, t) {
|
|
2591
2688
|
let n = H(e), r = new Headers(n.headers);
|
|
2592
|
-
t(r),
|
|
2689
|
+
t(r), qn(e, new Request(n, { headers: r }));
|
|
2593
2690
|
}
|
|
2594
2691
|
function W(e) {
|
|
2595
2692
|
let t = e.res;
|
|
@@ -2606,7 +2703,7 @@ function W(e) {
|
|
|
2606
2703
|
}
|
|
2607
2704
|
//#endregion
|
|
2608
2705
|
//#region src/data-plane/handlers/cors.ts
|
|
2609
|
-
var
|
|
2706
|
+
var Qn = e.object({
|
|
2610
2707
|
origins: e.array(e.string()).optional(),
|
|
2611
2708
|
allow_credentials: e.boolean().optional(),
|
|
2612
2709
|
allow_headers: e.array(e.string()).optional(),
|
|
@@ -2618,9 +2715,9 @@ function G(e, t) {
|
|
|
2618
2715
|
let n = new Headers(), r = e.origins ?? ["*"], i = r.includes("*");
|
|
2619
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;
|
|
2620
2717
|
}
|
|
2621
|
-
var
|
|
2718
|
+
var $n = I({
|
|
2622
2719
|
type: "cors",
|
|
2623
|
-
optionsSchema:
|
|
2720
|
+
optionsSchema: Qn,
|
|
2624
2721
|
build(e) {
|
|
2625
2722
|
return async (t, n) => {
|
|
2626
2723
|
let r = t.req.header("origin") ?? null;
|
|
@@ -2638,20 +2735,20 @@ var qn = I({
|
|
|
2638
2735
|
});
|
|
2639
2736
|
};
|
|
2640
2737
|
}
|
|
2641
|
-
}),
|
|
2738
|
+
}), er = e.object({
|
|
2642
2739
|
username: e.string(),
|
|
2643
2740
|
password: e.string(),
|
|
2644
2741
|
realm: e.string().optional()
|
|
2645
2742
|
});
|
|
2646
|
-
function
|
|
2743
|
+
function tr(e, t) {
|
|
2647
2744
|
let n = `${e}:${t}`;
|
|
2648
2745
|
return typeof btoa == "function" ? btoa(n) : Buffer.from(n, "utf-8").toString("base64");
|
|
2649
2746
|
}
|
|
2650
|
-
var
|
|
2747
|
+
var nr = I({
|
|
2651
2748
|
type: "basic_auth",
|
|
2652
|
-
optionsSchema:
|
|
2749
|
+
optionsSchema: er,
|
|
2653
2750
|
build(e) {
|
|
2654
|
-
let t =
|
|
2751
|
+
let t = tr(e.username, e.password), n = (e.realm ?? "Restricted").replace(/["\\\r\n]/g, "");
|
|
2655
2752
|
return async (e, r) => {
|
|
2656
2753
|
let i = e.req.header("authorization");
|
|
2657
2754
|
if (i) {
|
|
@@ -2667,7 +2764,7 @@ var Xn = I({
|
|
|
2667
2764
|
});
|
|
2668
2765
|
};
|
|
2669
2766
|
}
|
|
2670
|
-
}),
|
|
2767
|
+
}), rr = I({
|
|
2671
2768
|
type: "headers",
|
|
2672
2769
|
optionsSchema: e.object({
|
|
2673
2770
|
request: e.record(e.string(), e.string()).optional(),
|
|
@@ -2682,7 +2779,7 @@ var Xn = I({
|
|
|
2682
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);
|
|
2683
2780
|
};
|
|
2684
2781
|
}
|
|
2685
|
-
}),
|
|
2782
|
+
}), ir = I({
|
|
2686
2783
|
type: "cache",
|
|
2687
2784
|
optionsSchema: e.object({ ttl_seconds: e.number().int().positive() }),
|
|
2688
2785
|
build(e) {
|
|
@@ -2693,7 +2790,7 @@ var Xn = I({
|
|
|
2693
2790
|
}
|
|
2694
2791
|
};
|
|
2695
2792
|
}
|
|
2696
|
-
}),
|
|
2793
|
+
}), ar = I({
|
|
2697
2794
|
type: "forwarded_headers",
|
|
2698
2795
|
optionsSchema: e.object({
|
|
2699
2796
|
client_ip_header: e.string().default("cf-connecting-ip"),
|
|
@@ -2710,33 +2807,33 @@ var Xn = I({
|
|
|
2710
2807
|
}), await n();
|
|
2711
2808
|
};
|
|
2712
2809
|
}
|
|
2713
|
-
}),
|
|
2714
|
-
function
|
|
2810
|
+
}), or = e.object({ upstream_host: e.string().optional() });
|
|
2811
|
+
function sr(e) {
|
|
2715
2812
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
2716
2813
|
}
|
|
2717
|
-
function
|
|
2814
|
+
function cr(e) {
|
|
2718
2815
|
if (typeof e.getSetCookie == "function") return e.getSetCookie();
|
|
2719
2816
|
let t = [];
|
|
2720
2817
|
return e.forEach((e, n) => {
|
|
2721
2818
|
n.toLowerCase() === "set-cookie" && t.push(e);
|
|
2722
2819
|
}), t;
|
|
2723
2820
|
}
|
|
2724
|
-
var
|
|
2821
|
+
var lr = I({
|
|
2725
2822
|
type: "rewrite_cookies",
|
|
2726
|
-
optionsSchema:
|
|
2823
|
+
optionsSchema: or,
|
|
2727
2824
|
build(e) {
|
|
2728
2825
|
return async (t, n) => {
|
|
2729
2826
|
await n();
|
|
2730
2827
|
let r = new URL(t.req.url).hostname, i = e.upstream_host ?? t.get("__proxy_upstream_host__");
|
|
2731
2828
|
if (!i) return;
|
|
2732
|
-
let a =
|
|
2829
|
+
let a = cr(t.res.headers);
|
|
2733
2830
|
if (a.length === 0) return;
|
|
2734
|
-
let o =
|
|
2831
|
+
let o = sr(i), s = RegExp(`(?:^|;\\s*)Domain=\\.?${o}(?=;|$)`, "i");
|
|
2735
2832
|
W(t), t.res.headers.delete("set-cookie");
|
|
2736
2833
|
for (let e of a) t.res.headers.append("set-cookie", e.replace(s, `Domain=${r}`));
|
|
2737
2834
|
};
|
|
2738
2835
|
}
|
|
2739
|
-
}),
|
|
2836
|
+
}), ur = I({
|
|
2740
2837
|
type: "rewrite_location",
|
|
2741
2838
|
optionsSchema: e.object({ upstream_origin: e.string().optional() }),
|
|
2742
2839
|
build(e) {
|
|
@@ -2759,14 +2856,14 @@ var rr = I({
|
|
|
2759
2856
|
W(t), t.res.headers.set("location", c);
|
|
2760
2857
|
};
|
|
2761
2858
|
}
|
|
2762
|
-
}),
|
|
2859
|
+
}), dr = class extends Error {
|
|
2763
2860
|
ms;
|
|
2764
2861
|
constructor(e, t) {
|
|
2765
2862
|
super(`${t ?? "Operation"} timed out after ${e}ms`), this.name = "TimeoutError", this.ms = e;
|
|
2766
2863
|
}
|
|
2767
2864
|
};
|
|
2768
2865
|
function K(e) {
|
|
2769
|
-
return e instanceof
|
|
2866
|
+
return e instanceof dr ? !0 : e instanceof Error ? e.name === "AbortError" || e.name === "TimeoutError" : !1;
|
|
2770
2867
|
}
|
|
2771
2868
|
function q(e, t) {
|
|
2772
2869
|
let n = new AbortController(), r = setTimeout(() => n.abort(), e);
|
|
@@ -2774,7 +2871,7 @@ function q(e, t) {
|
|
|
2774
2871
|
}
|
|
2775
2872
|
function J(e, t, n) {
|
|
2776
2873
|
let r, i = new Promise((e, i) => {
|
|
2777
|
-
r = setTimeout(() => i(new
|
|
2874
|
+
r = setTimeout(() => i(new dr(t, n)), t);
|
|
2778
2875
|
});
|
|
2779
2876
|
return Promise.race([e, i]).finally(() => {
|
|
2780
2877
|
r && clearTimeout(r);
|
|
@@ -2782,7 +2879,7 @@ function J(e, t, n) {
|
|
|
2782
2879
|
}
|
|
2783
2880
|
//#endregion
|
|
2784
2881
|
//#region src/data-plane/handlers/http.ts
|
|
2785
|
-
var
|
|
2882
|
+
var fr = /* @__PURE__ */ new Set([
|
|
2786
2883
|
"connection",
|
|
2787
2884
|
"keep-alive",
|
|
2788
2885
|
"proxy-authenticate",
|
|
@@ -2791,24 +2888,24 @@ var or = /* @__PURE__ */ new Set([
|
|
|
2791
2888
|
"trailers",
|
|
2792
2889
|
"transfer-encoding",
|
|
2793
2890
|
"upgrade"
|
|
2794
|
-
]),
|
|
2891
|
+
]), pr = 3e4, mr = e.object({
|
|
2795
2892
|
upstream_url: e.string(),
|
|
2796
2893
|
preserve_host: e.boolean().default(!1),
|
|
2797
2894
|
timeout_ms: e.number().int().positive().optional()
|
|
2798
2895
|
});
|
|
2799
|
-
function
|
|
2896
|
+
function hr(e, t) {
|
|
2800
2897
|
return e === "" || e === "/" ? t : `${e.endsWith("/") ? e.slice(0, -1) : e}${t.startsWith("/") ? t : `/${t}`}`;
|
|
2801
2898
|
}
|
|
2802
|
-
function
|
|
2899
|
+
function gr(e) {
|
|
2803
2900
|
return e !== "GET" && e !== "HEAD";
|
|
2804
2901
|
}
|
|
2805
|
-
function
|
|
2902
|
+
function _r(e, t) {
|
|
2806
2903
|
let n = new URL(t.url), r = new URL(e.upstream_url);
|
|
2807
|
-
r.pathname =
|
|
2904
|
+
r.pathname = hr(r.pathname, n.pathname), r.search = n.search;
|
|
2808
2905
|
let i = new Headers(t.headers);
|
|
2809
|
-
for (let e of
|
|
2906
|
+
for (let e of fr) i.delete(e);
|
|
2810
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(":", ""));
|
|
2811
|
-
let a =
|
|
2908
|
+
let a = gr(t.method) ? t.body : void 0, o = {
|
|
2812
2909
|
method: t.method,
|
|
2813
2910
|
headers: i,
|
|
2814
2911
|
body: a,
|
|
@@ -2819,13 +2916,13 @@ function dr(e, t) {
|
|
|
2819
2916
|
init: o
|
|
2820
2917
|
};
|
|
2821
2918
|
}
|
|
2822
|
-
var
|
|
2919
|
+
var vr = I({
|
|
2823
2920
|
type: "http",
|
|
2824
|
-
optionsSchema:
|
|
2921
|
+
optionsSchema: mr,
|
|
2825
2922
|
build(e) {
|
|
2826
|
-
let t = e.timeout_ms ??
|
|
2923
|
+
let t = e.timeout_ms ?? pr;
|
|
2827
2924
|
return async (n) => {
|
|
2828
|
-
let { target: r, init: i } =
|
|
2925
|
+
let { target: r, init: i } = _r(e, H(n));
|
|
2829
2926
|
n.set("__proxy_upstream_host__", r.hostname), n.set("__proxy_upstream_origin__", `${r.protocol}//${r.host}`);
|
|
2830
2927
|
try {
|
|
2831
2928
|
return await q(t, (e) => fetch(r.toString(), {
|
|
@@ -2837,24 +2934,24 @@ var fr = I({
|
|
|
2837
2934
|
}
|
|
2838
2935
|
};
|
|
2839
2936
|
}
|
|
2840
|
-
}),
|
|
2937
|
+
}), yr = 3e4, br = e.object({
|
|
2841
2938
|
binding: e.string(),
|
|
2842
2939
|
upstream_url: e.string().optional(),
|
|
2843
2940
|
preserve_host: e.boolean().default(!0),
|
|
2844
2941
|
timeout_ms: e.number().int().positive().optional()
|
|
2845
2942
|
});
|
|
2846
|
-
function
|
|
2943
|
+
function xr(e) {
|
|
2847
2944
|
return typeof e == "object" && !!e && typeof e.fetch == "function";
|
|
2848
2945
|
}
|
|
2849
|
-
var
|
|
2946
|
+
var Sr = I({
|
|
2850
2947
|
type: "service_binding",
|
|
2851
|
-
optionsSchema:
|
|
2948
|
+
optionsSchema: br,
|
|
2852
2949
|
build(e, t) {
|
|
2853
2950
|
let n = t.bindings[e.binding];
|
|
2854
|
-
if (!
|
|
2855
|
-
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;
|
|
2856
2953
|
return async (t) => {
|
|
2857
|
-
let a = H(t), { target: o, init: s } =
|
|
2954
|
+
let a = H(t), { target: o, init: s } = _r({
|
|
2858
2955
|
upstream_url: r,
|
|
2859
2956
|
preserve_host: e.preserve_host
|
|
2860
2957
|
}, a);
|
|
@@ -2869,34 +2966,34 @@ var gr = I({
|
|
|
2869
2966
|
}
|
|
2870
2967
|
};
|
|
2871
2968
|
}
|
|
2872
|
-
}),
|
|
2969
|
+
}), Cr = 3e4, wr = e.object({
|
|
2873
2970
|
binding: e.string(),
|
|
2874
2971
|
script_name: e.string(),
|
|
2875
2972
|
cpu_ms: e.number().int().positive().optional(),
|
|
2876
2973
|
subrequests: e.number().int().positive().optional(),
|
|
2877
2974
|
timeout_ms: e.number().int().positive().optional()
|
|
2878
2975
|
});
|
|
2879
|
-
function
|
|
2976
|
+
function Tr(e) {
|
|
2880
2977
|
return typeof e == "object" && !!e && typeof e.get == "function";
|
|
2881
2978
|
}
|
|
2882
2979
|
var Y = /\{(tenant_id|custom_domain_id|domain|host)\}/g;
|
|
2883
|
-
function
|
|
2980
|
+
function Er(e) {
|
|
2884
2981
|
return Y.lastIndex = 0, Y.test(e);
|
|
2885
2982
|
}
|
|
2886
|
-
var
|
|
2983
|
+
var Dr = I({
|
|
2887
2984
|
type: "dispatch_namespace",
|
|
2888
|
-
optionsSchema:
|
|
2985
|
+
optionsSchema: wr,
|
|
2889
2986
|
build(e, t) {
|
|
2890
2987
|
let n = t.bindings[e.binding];
|
|
2891
|
-
if (!
|
|
2892
|
-
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: {
|
|
2893
2990
|
...e.cpu_ms ? { cpuMs: e.cpu_ms } : {},
|
|
2894
2991
|
...e.subrequests ? { subrequests: e.subrequests } : {}
|
|
2895
2992
|
} } : void 0;
|
|
2896
2993
|
return async (t) => {
|
|
2897
2994
|
let o = e.script_name;
|
|
2898
2995
|
if (r) {
|
|
2899
|
-
let n =
|
|
2996
|
+
let n = Yn(t), r = Xn(t), i = Zn(t), a = t.req.header("host") ?? t.req.header("x-forwarded-host") ?? "";
|
|
2900
2997
|
if (o = o.replace(Y, (e, t) => {
|
|
2901
2998
|
switch (t) {
|
|
2902
2999
|
case "tenant_id": return n ?? "";
|
|
@@ -2919,7 +3016,7 @@ var xr = I({
|
|
|
2919
3016
|
}
|
|
2920
3017
|
};
|
|
2921
3018
|
}
|
|
2922
|
-
}),
|
|
3019
|
+
}), Or = I({
|
|
2923
3020
|
type: "redirect",
|
|
2924
3021
|
optionsSchema: e.object({
|
|
2925
3022
|
upstream_url: e.string().refine((e) => {
|
|
@@ -2948,7 +3045,7 @@ var xr = I({
|
|
|
2948
3045
|
});
|
|
2949
3046
|
};
|
|
2950
3047
|
}
|
|
2951
|
-
}),
|
|
3048
|
+
}), kr = I({
|
|
2952
3049
|
type: "static",
|
|
2953
3050
|
optionsSchema: e.object({
|
|
2954
3051
|
status: e.number().int().default(200),
|
|
@@ -2968,15 +3065,15 @@ var xr = I({
|
|
|
2968
3065
|
});
|
|
2969
3066
|
//#endregion
|
|
2970
3067
|
//#region src/data-plane/handlers/index.ts
|
|
2971
|
-
function
|
|
2972
|
-
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);
|
|
2973
3070
|
}
|
|
2974
3071
|
//#endregion
|
|
2975
3072
|
//#region src/data-plane/matcher.ts
|
|
2976
3073
|
function X(e) {
|
|
2977
3074
|
return [...e].sort((e, t) => e.priority === t.priority ? e.created_at.localeCompare(t.created_at) : e.priority - t.priority);
|
|
2978
3075
|
}
|
|
2979
|
-
function
|
|
3076
|
+
function jr(e, t) {
|
|
2980
3077
|
let n = e.toLowerCase(), r = t.toLowerCase();
|
|
2981
3078
|
if (n === r) return !0;
|
|
2982
3079
|
if (n.startsWith("*.")) {
|
|
@@ -2985,13 +3082,16 @@ function Tr(e, t) {
|
|
|
2985
3082
|
}
|
|
2986
3083
|
return !1;
|
|
2987
3084
|
}
|
|
2988
|
-
function
|
|
2989
|
-
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));
|
|
2990
3087
|
}
|
|
2991
|
-
function
|
|
3088
|
+
function Nr(e) {
|
|
2992
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;
|
|
2993
3090
|
return async (e, i) => {
|
|
2994
|
-
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
|
+
}
|
|
2995
3095
|
for (let [n, r] of t) {
|
|
2996
3096
|
let t = e.req.header(n);
|
|
2997
3097
|
if (t === void 0 || !r.test(t)) return new Response("No matching route", { status: 404 });
|
|
@@ -3008,7 +3108,7 @@ function Dr(e) {
|
|
|
3008
3108
|
}
|
|
3009
3109
|
//#endregion
|
|
3010
3110
|
//#region src/data-plane/compile.ts
|
|
3011
|
-
var
|
|
3111
|
+
var Pr = [
|
|
3012
3112
|
"GET",
|
|
3013
3113
|
"POST",
|
|
3014
3114
|
"PUT",
|
|
@@ -3020,34 +3120,34 @@ var Or = [
|
|
|
3020
3120
|
function Z(e, n, r, i) {
|
|
3021
3121
|
let a = new t();
|
|
3022
3122
|
r && a.use("*", async (e, t) => {
|
|
3023
|
-
|
|
3123
|
+
Jn(e, r), await t();
|
|
3024
3124
|
});
|
|
3025
3125
|
let o = X(e);
|
|
3026
3126
|
for (let e of o) {
|
|
3027
3127
|
let t = [];
|
|
3028
|
-
t.push(
|
|
3128
|
+
t.push(Nr(e.match));
|
|
3029
3129
|
for (let r of e.handlers) t.push(n.build(r.type, r.options));
|
|
3030
|
-
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 || "/*";
|
|
3031
3131
|
a.on(r, [i], ...t);
|
|
3032
3132
|
}
|
|
3033
|
-
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) => {
|
|
3034
3134
|
let n = K(e);
|
|
3035
3135
|
return t.text(n ? "Upstream timeout" : "Bad gateway", n ? 504 : 502, { "x-authhero-proxy-error": n ? "handler_timeout" : "handler_failed" });
|
|
3036
3136
|
}), a;
|
|
3037
3137
|
}
|
|
3038
3138
|
//#endregion
|
|
3039
3139
|
//#region src/data-plane/router.ts
|
|
3040
|
-
var
|
|
3041
|
-
function
|
|
3140
|
+
var Fr = 1e4;
|
|
3141
|
+
function Ir(e) {
|
|
3042
3142
|
return e.resolver ? e.resolver : e.cache ? P(e.data, e.cache) : P(e.data, e.cacheTtlMs ?? 3e4);
|
|
3043
3143
|
}
|
|
3044
|
-
function
|
|
3144
|
+
function Lr(e) {
|
|
3045
3145
|
if (e.registry) return e.registry;
|
|
3046
3146
|
let t = new F(e.bindings ?? {});
|
|
3047
|
-
return
|
|
3147
|
+
return Ar(t), t;
|
|
3048
3148
|
}
|
|
3049
3149
|
function Q(e) {
|
|
3050
|
-
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;
|
|
3051
3151
|
return async (e) => {
|
|
3052
3152
|
let s = e.req.header("host") ?? e.req.header("x-forwarded-host");
|
|
3053
3153
|
if (!s) return e.text("Missing host", 400);
|
|
@@ -3065,13 +3165,13 @@ function Q(e) {
|
|
|
3065
3165
|
}
|
|
3066
3166
|
};
|
|
3067
3167
|
}
|
|
3068
|
-
function
|
|
3168
|
+
function Rr(e) {
|
|
3069
3169
|
let n = new t();
|
|
3070
3170
|
return n.all("*", Q(e)), n;
|
|
3071
3171
|
}
|
|
3072
3172
|
//#endregion
|
|
3073
3173
|
//#region src/app.ts
|
|
3074
|
-
function
|
|
3174
|
+
function zr(e) {
|
|
3075
3175
|
let n = new t();
|
|
3076
3176
|
return n.all("*", Q({
|
|
3077
3177
|
data: e.data,
|
|
@@ -3089,17 +3189,17 @@ function Nr(e) {
|
|
|
3089
3189
|
}
|
|
3090
3190
|
//#endregion
|
|
3091
3191
|
//#region src/data-plane/cache-api-cache.ts
|
|
3092
|
-
var
|
|
3093
|
-
function
|
|
3192
|
+
var Br = 1e3, Vr = 1e3;
|
|
3193
|
+
function Hr(e, t) {
|
|
3094
3194
|
return new Request(`https://proxy-cache.internal/${encodeURIComponent(e)}/hosts/${encodeURIComponent(t.toLowerCase())}`, { method: "GET" });
|
|
3095
3195
|
}
|
|
3096
|
-
function
|
|
3196
|
+
function Ur() {
|
|
3097
3197
|
return globalThis.caches?.default;
|
|
3098
3198
|
}
|
|
3099
|
-
function
|
|
3100
|
-
let t = e.cache ??
|
|
3199
|
+
function Wr(e) {
|
|
3200
|
+
let t = e.cache ?? Ur();
|
|
3101
3201
|
if (!t) return e.upstream;
|
|
3102
|
-
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;
|
|
3103
3203
|
async function l(e) {
|
|
3104
3204
|
try {
|
|
3105
3205
|
return await J(Promise.resolve(n.match(e)), s, "cache.match");
|
|
@@ -3108,7 +3208,7 @@ function Rr(e) {
|
|
|
3108
3208
|
}
|
|
3109
3209
|
}
|
|
3110
3210
|
return { async resolveHost(t) {
|
|
3111
|
-
let s =
|
|
3211
|
+
let s = Hr(r, t), u = await l(s);
|
|
3112
3212
|
if (u) try {
|
|
3113
3213
|
return (await u.json()).value;
|
|
3114
3214
|
} catch {}
|
|
@@ -3119,14 +3219,14 @@ function Rr(e) {
|
|
|
3119
3219
|
return o ? o(m) : await m, d;
|
|
3120
3220
|
} };
|
|
3121
3221
|
}
|
|
3122
|
-
function
|
|
3123
|
-
return
|
|
3222
|
+
function Gr(e, t) {
|
|
3223
|
+
return Hr(e, t);
|
|
3124
3224
|
}
|
|
3125
3225
|
//#endregion
|
|
3126
3226
|
//#region src/data-plane/cache-adapter-cache.ts
|
|
3127
|
-
var
|
|
3128
|
-
function
|
|
3129
|
-
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();
|
|
3130
3230
|
function f(e) {
|
|
3131
3231
|
return `${s}:${e.toLowerCase()}`;
|
|
3132
3232
|
}
|
|
@@ -3179,7 +3279,7 @@ function Hr(e) {
|
|
|
3179
3279
|
}
|
|
3180
3280
|
} };
|
|
3181
3281
|
}
|
|
3182
|
-
function
|
|
3282
|
+
function Yr(e, t) {
|
|
3183
3283
|
return `${e}:${t.toLowerCase()}`;
|
|
3184
3284
|
}
|
|
3185
3285
|
//#endregion
|
|
@@ -3187,7 +3287,7 @@ function Ur(e, t) {
|
|
|
3187
3287
|
function $() {
|
|
3188
3288
|
throw Error("Static proxy adapter is read-only; configure routes at init time");
|
|
3189
3289
|
}
|
|
3190
|
-
function
|
|
3290
|
+
function Xr(e, t, n, r, i, a) {
|
|
3191
3291
|
return {
|
|
3192
3292
|
id: e.id ?? `${n}:${t}`,
|
|
3193
3293
|
tenant_id: r,
|
|
@@ -3202,10 +3302,10 @@ function Wr(e, t, n, r, i, a) {
|
|
|
3202
3302
|
updated_at: e.updated_at ?? a
|
|
3203
3303
|
};
|
|
3204
3304
|
}
|
|
3205
|
-
function
|
|
3305
|
+
function Zr(e) {
|
|
3206
3306
|
let t = (/* @__PURE__ */ new Date()).toISOString(), n = e.defaultTenantId ?? "static", r = /* @__PURE__ */ new Map();
|
|
3207
3307
|
for (let [i, a] of Object.entries(e.hosts)) {
|
|
3208
|
-
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);
|
|
3209
3309
|
r.set(e, {
|
|
3210
3310
|
tenant_id: s,
|
|
3211
3311
|
custom_domain_id: c,
|
|
@@ -3249,7 +3349,7 @@ function Gr(e) {
|
|
|
3249
3349
|
}
|
|
3250
3350
|
};
|
|
3251
3351
|
}
|
|
3252
|
-
function
|
|
3352
|
+
function Qr(e, t = {}) {
|
|
3253
3353
|
return {
|
|
3254
3354
|
priority: t.priority,
|
|
3255
3355
|
match: { path: t.path ?? "/*" },
|
|
@@ -3264,10 +3364,10 @@ function Kr(e, t = {}) {
|
|
|
3264
3364
|
}
|
|
3265
3365
|
//#endregion
|
|
3266
3366
|
//#region src/constants.ts
|
|
3267
|
-
var
|
|
3367
|
+
var $r = "proxy:resolve_host";
|
|
3268
3368
|
//#endregion
|
|
3269
3369
|
//#region src/http-adapter/index.ts
|
|
3270
|
-
function
|
|
3370
|
+
function ei() {
|
|
3271
3371
|
let e = () => {
|
|
3272
3372
|
throw Error("HTTP proxy adapter does not expose write access to proxy_routes; mutate via the control-plane management API");
|
|
3273
3373
|
};
|
|
@@ -3289,7 +3389,7 @@ function Jr() {
|
|
|
3289
3389
|
}
|
|
3290
3390
|
};
|
|
3291
3391
|
}
|
|
3292
|
-
function
|
|
3392
|
+
function ti(e) {
|
|
3293
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;
|
|
3294
3394
|
function c(e) {
|
|
3295
3395
|
let t = new AbortController(), n = setTimeout(() => t.abort(), s);
|
|
@@ -3322,7 +3422,7 @@ function Yr(e) {
|
|
|
3322
3422
|
}), u);
|
|
3323
3423
|
}
|
|
3324
3424
|
return {
|
|
3325
|
-
proxyRoutes:
|
|
3425
|
+
proxyRoutes: ei(),
|
|
3326
3426
|
async resolveHost(e) {
|
|
3327
3427
|
let i = await f(), a = `${n}${r}${encodeURIComponent(e.toLowerCase())}`, o = await c((e) => t(a, {
|
|
3328
3428
|
headers: { authorization: `Bearer ${i}` },
|
|
@@ -3336,11 +3436,11 @@ function Yr(e) {
|
|
|
3336
3436
|
}
|
|
3337
3437
|
//#endregion
|
|
3338
3438
|
//#region src/kv-adapter/index.ts
|
|
3339
|
-
var
|
|
3340
|
-
function
|
|
3439
|
+
var ni = "authhero-proxy-host:";
|
|
3440
|
+
function ri(e, t) {
|
|
3341
3441
|
return `${e}${t.toLowerCase()}`;
|
|
3342
3442
|
}
|
|
3343
|
-
function
|
|
3443
|
+
function ii() {
|
|
3344
3444
|
let e = () => {
|
|
3345
3445
|
throw Error("KV proxy adapter does not expose write access to proxy_routes; mutate via the control-plane management API");
|
|
3346
3446
|
};
|
|
@@ -3362,15 +3462,15 @@ function Qr() {
|
|
|
3362
3462
|
}
|
|
3363
3463
|
};
|
|
3364
3464
|
}
|
|
3365
|
-
function
|
|
3366
|
-
let { kv: t, keyPrefix: n =
|
|
3465
|
+
function ai(e) {
|
|
3466
|
+
let { kv: t, keyPrefix: n = ni, timeoutMs: r } = e;
|
|
3367
3467
|
return {
|
|
3368
|
-
proxyRoutes:
|
|
3468
|
+
proxyRoutes: ii(),
|
|
3369
3469
|
async resolveHost(e) {
|
|
3370
|
-
let i =
|
|
3470
|
+
let i = ri(n, e), a = t.get(i, "json");
|
|
3371
3471
|
return (r && r > 0 ? await J(a, r, "kv.get") : await a) ?? null;
|
|
3372
3472
|
}
|
|
3373
3473
|
};
|
|
3374
3474
|
}
|
|
3375
3475
|
//#endregion
|
|
3376
|
-
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 };
|