@authhero/proxy 0.10.11 → 0.10.13

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.mjs CHANGED
@@ -1151,7 +1151,7 @@ var y = e.object({
1151
1151
  xt,
1152
1152
  St,
1153
1153
  wt
1154
- ]), C = e.union([
1154
+ ]), Ot = e.union([
1155
1155
  Tt,
1156
1156
  Et,
1157
1157
  Dt
@@ -1181,22 +1181,22 @@ new Set([
1181
1181
  visible: e.boolean().optional().default(!0),
1182
1182
  customizations: e.record(e.string(), e.any()).optional()
1183
1183
  });
1184
- var w = e.object({
1184
+ var C = e.object({
1185
1185
  x: e.number(),
1186
1186
  y: e.number()
1187
- }), Ot = e.object({
1187
+ }), kt = e.object({
1188
1188
  id: e.string(),
1189
1189
  type: e.literal("FLOW"),
1190
- coordinates: w,
1190
+ coordinates: C,
1191
1191
  alias: e.string().min(1).max(150).optional(),
1192
1192
  config: e.object({
1193
1193
  flow_id: e.string().max(30),
1194
1194
  next_node: e.string().optional()
1195
1195
  })
1196
- }), kt = e.object({
1196
+ }), At = e.object({
1197
1197
  id: e.string(),
1198
1198
  type: e.literal("ROUTER"),
1199
- coordinates: w,
1199
+ coordinates: C,
1200
1200
  alias: e.string().min(1).max(150),
1201
1201
  config: e.object({
1202
1202
  rules: e.array(e.object({
@@ -1207,20 +1207,20 @@ var w = e.object({
1207
1207
  })),
1208
1208
  fallback: e.string()
1209
1209
  })
1210
- }), At = e.object({
1210
+ }), jt = e.object({
1211
1211
  id: e.string(),
1212
1212
  type: e.literal("STEP"),
1213
- coordinates: w,
1213
+ coordinates: C,
1214
1214
  alias: e.string().min(1).max(150).optional(),
1215
1215
  config: e.object({
1216
- components: e.array(C),
1216
+ components: e.array(Ot),
1217
1217
  next_node: e.string().optional()
1218
1218
  })
1219
- }), jt = e.discriminatedUnion("type", [
1220
- Ot,
1219
+ }), Mt = e.discriminatedUnion("type", [
1221
1220
  kt,
1222
- At
1223
- ]), Mt = e.object({
1221
+ At,
1222
+ jt
1223
+ ]), Nt = e.object({
1224
1224
  name: e.string().openapi({ description: "The name of the form" }),
1225
1225
  messages: e.object({
1226
1226
  errors: e.record(e.string(), e.any()).optional(),
@@ -1231,14 +1231,14 @@ var w = e.object({
1231
1231
  default: e.string().optional()
1232
1232
  }).optional(),
1233
1233
  translations: e.record(e.string(), e.any()).optional(),
1234
- nodes: e.array(jt).optional(),
1234
+ nodes: e.array(Mt).optional(),
1235
1235
  start: e.object({
1236
1236
  hidden_fields: e.array(e.object({
1237
1237
  key: e.string(),
1238
1238
  value: e.string()
1239
1239
  })).optional(),
1240
1240
  next_node: e.string().optional(),
1241
- coordinates: w.optional()
1241
+ coordinates: C.optional()
1242
1242
  }).optional(),
1243
1243
  ending: e.object({
1244
1244
  redirection: e.object({
@@ -1246,7 +1246,7 @@ var w = e.object({
1246
1246
  target: e.string().optional()
1247
1247
  }).optional(),
1248
1248
  after_submit: e.object({ flow_id: e.string().optional() }).optional(),
1249
- coordinates: w.optional(),
1249
+ coordinates: C.optional(),
1250
1250
  resume_flow: e.boolean().optional()
1251
1251
  }).optional(),
1252
1252
  style: e.object({ css: e.string().optional() }).optional(),
@@ -1255,8 +1255,8 @@ var w = e.object({
1255
1255
  sdk_src: e.string().optional()
1256
1256
  }).optional()
1257
1257
  }).openapi({ description: "Schema for flow-based forms (matches Auth0 Forms structure)" });
1258
- n.extend(Mt.shape).extend({ id: e.string() });
1259
- var Nt = e.object({
1258
+ n.extend(Nt.shape).extend({ id: e.string() });
1259
+ var Pt = e.object({
1260
1260
  id: e.number().optional(),
1261
1261
  text: e.string(),
1262
1262
  type: e.enum([
@@ -1265,7 +1265,7 @@ var Nt = e.object({
1265
1265
  "success",
1266
1266
  "warning"
1267
1267
  ])
1268
- }), Pt = e.object({
1268
+ }), Ft = e.object({
1269
1269
  id: e.string().optional(),
1270
1270
  text: e.string(),
1271
1271
  href: e.string(),
@@ -1277,12 +1277,12 @@ e.object({
1277
1277
  method: e.enum(["POST", "GET"]),
1278
1278
  title: e.string().optional(),
1279
1279
  description: e.string().optional(),
1280
- components: e.array(C),
1281
- messages: e.array(Nt).optional(),
1282
- links: e.array(Pt).optional(),
1280
+ components: e.array(Ot),
1281
+ messages: e.array(Pt).optional(),
1282
+ links: e.array(Ft).optional(),
1283
1283
  footer: e.string().optional()
1284
1284
  });
1285
- var T = e.enum([
1285
+ var w = e.enum([
1286
1286
  "pre-user-registration",
1287
1287
  "post-user-registration",
1288
1288
  "post-user-login",
@@ -1290,19 +1290,19 @@ var T = e.enum([
1290
1290
  "validate-registration-username",
1291
1291
  "pre-user-deletion",
1292
1292
  "post-user-deletion"
1293
- ]), E = e.enum(["post-user-login"]), D = e.enum([
1293
+ ]), T = e.enum(["post-user-login"]), E = e.enum([
1294
1294
  "post-user-login",
1295
1295
  "post-user-registration",
1296
1296
  "post-user-update",
1297
1297
  "credentials-exchange"
1298
- ]), O = e.enum([
1298
+ ]), D = e.enum([
1299
1299
  "post-user-login",
1300
1300
  "credentials-exchange",
1301
1301
  "pre-user-registration",
1302
1302
  "post-user-registration"
1303
- ]), k = e.enum(["post-user-login"]);
1304
- T.options, E.options, D.options, O.options, k.options;
1305
- var A = e.enum(["impersonate"]), Ft = e.enum([
1303
+ ]), O = e.enum(["post-user-login"]);
1304
+ w.options, T.options, E.options, D.options, O.options;
1305
+ var k = e.enum(["impersonate"]), A = e.enum([
1306
1306
  "ensure-username",
1307
1307
  "set-preferred-username",
1308
1308
  "account-linking"
@@ -1314,24 +1314,24 @@ var A = e.enum(["impersonate"]), Ft = e.enum([
1314
1314
  metadata: e.record(e.string(), e.unknown()).optional()
1315
1315
  }, It = e.object({
1316
1316
  ...j,
1317
- trigger_id: T,
1317
+ trigger_id: w,
1318
1318
  url: e.string()
1319
1319
  }), Lt = e.object({
1320
1320
  ...j,
1321
- trigger_id: E,
1321
+ trigger_id: T,
1322
1322
  form_id: e.string()
1323
1323
  }), Rt = e.object({
1324
1324
  ...j,
1325
- trigger_id: D,
1326
- template_id: Ft
1325
+ trigger_id: E,
1326
+ template_id: A
1327
1327
  }), zt = e.object({
1328
1328
  ...j,
1329
- trigger_id: O,
1329
+ trigger_id: D,
1330
1330
  code_id: e.string()
1331
1331
  }), Bt = e.object({
1332
1332
  ...j,
1333
- trigger_id: k,
1334
- page_id: A,
1333
+ trigger_id: O,
1334
+ page_id: k,
1335
1335
  permission_required: e.string().optional()
1336
1336
  });
1337
1337
  e.union([
@@ -1343,34 +1343,34 @@ e.union([
1343
1343
  ]);
1344
1344
  var Vt = e.object({
1345
1345
  ...j,
1346
- trigger_id: T
1346
+ trigger_id: w
1347
1347
  }).extend(n.shape).extend({
1348
1348
  hook_id: e.string(),
1349
1349
  url: e.string()
1350
1350
  }), Ht = e.object({
1351
1351
  ...j,
1352
- trigger_id: E
1352
+ trigger_id: T
1353
1353
  }).extend(n.shape).extend({
1354
1354
  hook_id: e.string(),
1355
1355
  form_id: e.string()
1356
1356
  }), Ut = e.object({
1357
1357
  ...j,
1358
- trigger_id: D
1358
+ trigger_id: E
1359
1359
  }).extend(n.shape).extend({
1360
1360
  hook_id: e.string(),
1361
- template_id: Ft
1361
+ template_id: A
1362
1362
  }), Wt = e.object({
1363
1363
  ...j,
1364
- trigger_id: O
1364
+ trigger_id: D
1365
1365
  }).extend(n.shape).extend({
1366
1366
  hook_id: e.string(),
1367
1367
  code_id: e.string()
1368
1368
  }), Gt = e.object({
1369
1369
  ...j,
1370
- trigger_id: k
1370
+ trigger_id: O
1371
1371
  }).extend(n.shape).extend({
1372
1372
  hook_id: e.string(),
1373
- page_id: A,
1373
+ page_id: k,
1374
1374
  permission_required: e.string().optional()
1375
1375
  });
1376
1376
  e.union([
@@ -2000,14 +2000,15 @@ var gn = e.enum([
2000
2000
  "seed",
2001
2001
  "upgrade",
2002
2002
  "backup",
2003
- "deprovision"
2003
+ "deprovision",
2004
+ "users_import"
2004
2005
  ]), _n = e.enum([
2005
2006
  "pending",
2006
2007
  "running",
2007
2008
  "succeeded",
2008
2009
  "failed",
2009
2010
  "cancelled"
2010
- ]), vn = e.enum(["inline", "cloudflare-workflows"]);
2011
+ ]), vn = e.string().max(64);
2011
2012
  e.object({
2012
2013
  tenant_id: e.string().max(255).nullable().default(null),
2013
2014
  rollout_id: e.string().max(255).nullable().optional(),
@@ -2016,12 +2017,16 @@ e.object({
2016
2017
  engine_instance_id: e.string().max(100).nullable().optional(),
2017
2018
  target_worker_version: e.string().max(255).nullable().optional(),
2018
2019
  target_database_version: e.string().max(255).nullable().optional(),
2019
- initiated_by: e.string().max(255).nullable().optional()
2020
+ initiated_by: e.string().max(255).nullable().optional(),
2021
+ input: e.record(e.string(), e.unknown()).nullable().optional()
2020
2022
  }).extend({
2021
2023
  id: e.string(),
2022
2024
  status: _n,
2023
2025
  current_step: e.string().max(255).nullable().optional(),
2024
2026
  error: e.string().nullable().optional(),
2027
+ result: e.record(e.string(), e.unknown()).nullable().optional(),
2028
+ claimed_by: e.string().max(255).nullable().optional(),
2029
+ claim_expires_at: e.string().nullable().optional(),
2025
2030
  created_at: e.string(),
2026
2031
  updated_at: e.string(),
2027
2032
  finished_at: e.string().nullable().optional()
@@ -2032,6 +2037,9 @@ e.object({
2032
2037
  target_worker_version: !0,
2033
2038
  target_database_version: !0,
2034
2039
  error: !0,
2040
+ result: !0,
2041
+ claimed_by: !0,
2042
+ claim_expires_at: !0,
2035
2043
  finished_at: !0
2036
2044
  }).partial();
2037
2045
  var yn = e.enum([
@@ -2052,6 +2060,34 @@ e.object({
2052
2060
  id: e.string(),
2053
2061
  created_at: e.string()
2054
2062
  });
2063
+ var N = e.enum([
2064
+ "pending",
2065
+ "inserted",
2066
+ "updated",
2067
+ "failed",
2068
+ "skipped"
2069
+ ]);
2070
+ e.object({
2071
+ operation_id: e.string().max(255),
2072
+ seq: e.number().int().min(0),
2073
+ payload: e.record(e.string(), e.unknown()),
2074
+ status: N.default("pending"),
2075
+ error_code: e.string().max(64).nullable().optional(),
2076
+ error_message: e.string().nullable().optional(),
2077
+ error_path: e.string().max(255).nullable().optional(),
2078
+ entity_id: e.string().max(255).nullable().optional()
2079
+ }).extend({
2080
+ status: N,
2081
+ created_at: e.string(),
2082
+ updated_at: e.string()
2083
+ }), e.object({
2084
+ seq: e.number().int().min(0),
2085
+ status: N,
2086
+ error_code: e.string().max(64).nullable().optional(),
2087
+ error_message: e.string().nullable().optional(),
2088
+ error_path: e.string().max(255).nullable().optional(),
2089
+ entity_id: e.string().max(255).nullable().optional()
2090
+ });
2055
2091
  var bn = e.enum([
2056
2092
  "upgrade",
2057
2093
  "reseed",
@@ -2138,19 +2174,19 @@ var Sn = e.object({
2138
2174
  success: e.string(),
2139
2175
  widget_background: e.string(),
2140
2176
  widget_border: e.string()
2141
- }), N = e.object({
2177
+ }), P = e.object({
2142
2178
  bold: e.boolean(),
2143
2179
  size: e.number()
2144
2180
  }), wn = e.object({
2145
- body_text: N,
2146
- buttons_text: N,
2181
+ body_text: P,
2182
+ buttons_text: P,
2147
2183
  font_url: e.string(),
2148
- input_labels: N,
2149
- links: N,
2184
+ input_labels: P,
2185
+ links: P,
2150
2186
  links_style: e.enum(["normal", "underlined"]),
2151
2187
  reference_text_size: e.number(),
2152
- subtitle: N,
2153
- title: N
2188
+ subtitle: P,
2189
+ title: P
2154
2190
  }), Tn = e.object({
2155
2191
  background_color: e.string(),
2156
2192
  background_image_url: e.string(),
@@ -2203,18 +2239,18 @@ var Dn = e.object({
2203
2239
  }), On = e.object({
2204
2240
  type: e.string(),
2205
2241
  options: e.record(e.string(), e.unknown()).default({})
2206
- }), P = e.object({
2242
+ }), F = e.object({
2207
2243
  id: e.string().optional(),
2208
2244
  custom_domain_id: e.string(),
2209
2245
  priority: e.number().int().default(100),
2210
2246
  match: Dn,
2211
2247
  handlers: e.array(On).min(1)
2212
- }), kn = P.extend({
2248
+ }), kn = F.extend({
2213
2249
  id: e.string(),
2214
2250
  tenant_id: e.string(),
2215
2251
  created_at: e.string(),
2216
2252
  updated_at: e.string()
2217
- }), An = P.partial().omit({
2253
+ }), An = F.partial().omit({
2218
2254
  id: !0,
2219
2255
  custom_domain_id: !0
2220
2256
  }), jn = e.object({
@@ -2649,7 +2685,7 @@ var er = e.enum([
2649
2685
  friendly_name: e.string().optional(),
2650
2686
  confirmed: e.boolean().default(!1)
2651
2687
  });
2652
- function F(t, n) {
2688
+ function I(t, n) {
2653
2689
  t.type === "phone" && !t.phone_number && n.addIssue({
2654
2690
  code: e.ZodIssueCode.custom,
2655
2691
  message: "phone_number is required when type is 'phone'",
@@ -2672,17 +2708,17 @@ function F(t, n) {
2672
2708
  path: ["public_key"]
2673
2709
  }));
2674
2710
  }
2675
- tr.superRefine(F), tr.extend({
2711
+ tr.superRefine(I), tr.extend({
2676
2712
  id: e.string(),
2677
2713
  created_at: e.string(),
2678
2714
  updated_at: e.string()
2679
- }).superRefine(F), e.object({
2715
+ }).superRefine(I), e.object({
2680
2716
  id: e.string().optional(),
2681
2717
  created_at: e.string().datetime({ offset: !0 }).optional(),
2682
2718
  updated_at: e.string().datetime({ offset: !0 }).optional()
2683
2719
  });
2684
2720
  var nr = "x-authhero-preserve-location", rr = 1e4;
2685
- function I(e, t, n) {
2721
+ function L(e, t, n) {
2686
2722
  let r = typeof t == "number" ? {
2687
2723
  freshTtlMs: t,
2688
2724
  maxEntries: n
@@ -2743,7 +2779,7 @@ function I(e, t, n) {
2743
2779
  }
2744
2780
  //#endregion
2745
2781
  //#region src/data-plane/registry.ts
2746
- var L = class {
2782
+ var R = class {
2747
2783
  definitions = /* @__PURE__ */ new Map();
2748
2784
  bindings;
2749
2785
  constructor(e = {}) {
@@ -2763,23 +2799,20 @@ var L = class {
2763
2799
  return n.build(r.data, { bindings: this.bindings });
2764
2800
  }
2765
2801
  };
2766
- function R(e) {
2802
+ function z(e) {
2767
2803
  return e;
2768
2804
  }
2769
2805
  //#endregion
2770
2806
  //#region src/data-plane/handlers/util.ts
2771
- var z = "__authhero_proxy_request__", B = "__authhero_proxy_tenant_id__", V = "__authhero_proxy_custom_domain_id__", H = "__authhero_proxy_domain__", ir = "x-authhero-proxy-mutability-probe";
2772
- function ar(e, t) {
2773
- e.set(z, t);
2807
+ var B = "__authhero_proxy_request__", V = "__authhero_proxy_tenant_id__", H = "__authhero_proxy_custom_domain_id__", ir = "__authhero_proxy_domain__", ar = "x-authhero-proxy-mutability-probe";
2808
+ function or(e, t) {
2809
+ e.set(B, t);
2774
2810
  }
2775
2811
  function U(e) {
2776
- return e.get(z) ?? e.req.raw;
2777
- }
2778
- function or(e, t) {
2779
- e.set(B, t.tenant_id), e.set(V, t.custom_domain_id), e.set(H, t.domain);
2812
+ return e.get(B) ?? e.req.raw;
2780
2813
  }
2781
- function sr(e) {
2782
- return e.get(B);
2814
+ function sr(e, t) {
2815
+ e.set(V, t.tenant_id), e.set(H, t.custom_domain_id), e.set(ir, t.domain);
2783
2816
  }
2784
2817
  function cr(e) {
2785
2818
  return e.get(V);
@@ -2787,14 +2820,17 @@ function cr(e) {
2787
2820
  function lr(e) {
2788
2821
  return e.get(H);
2789
2822
  }
2790
- function ur(e, t) {
2823
+ function ur(e) {
2824
+ return e.get(ir);
2825
+ }
2826
+ function dr(e, t) {
2791
2827
  let n = U(e), r = new Headers(n.headers);
2792
- t(r), ar(e, new Request(n, { headers: r }));
2828
+ t(r), or(e, new Request(n, { headers: r }));
2793
2829
  }
2794
2830
  function W(e) {
2795
2831
  let t = e.res;
2796
2832
  try {
2797
- t.headers.append(ir, "1"), t.headers.delete(ir);
2833
+ t.headers.append(ar, "1"), t.headers.delete(ar);
2798
2834
  return;
2799
2835
  } catch {
2800
2836
  e.res = new Response(t.body, {
@@ -2806,7 +2842,7 @@ function W(e) {
2806
2842
  }
2807
2843
  //#endregion
2808
2844
  //#region src/data-plane/handlers/cors.ts
2809
- var dr = e.object({
2845
+ var fr = e.object({
2810
2846
  origins: e.array(e.string()).optional(),
2811
2847
  allow_credentials: e.boolean().optional(),
2812
2848
  allow_headers: e.array(e.string()).optional(),
@@ -2814,44 +2850,44 @@ var dr = e.object({
2814
2850
  expose_headers: e.array(e.string()).optional(),
2815
2851
  max_age: e.number().int().optional()
2816
2852
  }).refine((e) => !(e.allow_credentials && e.origins?.includes("*")), { message: "Cannot use wildcard origin (*) with allow_credentials" });
2817
- function fr(e, t) {
2853
+ function pr(e, t) {
2818
2854
  let n = new Headers(), r = e.origins ?? ["*"], i = r.includes("*");
2819
2855
  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;
2820
2856
  }
2821
- var pr = R({
2857
+ var mr = z({
2822
2858
  type: "cors",
2823
- optionsSchema: dr,
2859
+ optionsSchema: fr,
2824
2860
  build(e) {
2825
2861
  return async (t, n) => {
2826
2862
  let r = t.req.header("origin") ?? null;
2827
2863
  if (t.req.method === "OPTIONS" && r !== null && t.req.header("access-control-request-method") !== void 0) {
2828
- let t = fr(e, r);
2864
+ let t = pr(e, r);
2829
2865
  return new Response(null, {
2830
2866
  status: 204,
2831
2867
  headers: t
2832
2868
  });
2833
2869
  }
2834
2870
  await n();
2835
- let i = fr(e, r);
2871
+ let i = pr(e, r);
2836
2872
  W(t), i.forEach((e, n) => {
2837
2873
  n.toLowerCase() === "vary" ? t.res.headers.append(n, e) : t.res.headers.set(n, e);
2838
2874
  });
2839
2875
  };
2840
2876
  }
2841
- }), mr = e.object({
2877
+ }), hr = e.object({
2842
2878
  username: e.string(),
2843
2879
  password: e.string(),
2844
2880
  realm: e.string().optional()
2845
2881
  });
2846
- function hr(e, t) {
2882
+ function gr(e, t) {
2847
2883
  let n = `${e}:${t}`;
2848
2884
  return typeof btoa == "function" ? btoa(n) : Buffer.from(n, "utf-8").toString("base64");
2849
2885
  }
2850
- var gr = R({
2886
+ var _r = z({
2851
2887
  type: "basic_auth",
2852
- optionsSchema: mr,
2888
+ optionsSchema: hr,
2853
2889
  build(e) {
2854
- let t = hr(e.username, e.password), n = (e.realm ?? "Restricted").replace(/["\\\r\n]/g, "");
2890
+ let t = gr(e.username, e.password), n = (e.realm ?? "Restricted").replace(/["\\\r\n]/g, "");
2855
2891
  return async (e, r) => {
2856
2892
  let i = e.req.header("authorization");
2857
2893
  if (i) {
@@ -2867,7 +2903,7 @@ var gr = R({
2867
2903
  });
2868
2904
  };
2869
2905
  }
2870
- }), _r = R({
2906
+ }), vr = z({
2871
2907
  type: "headers",
2872
2908
  optionsSchema: e.object({
2873
2909
  request: e.record(e.string(), e.string()).optional(),
@@ -2877,12 +2913,12 @@ var gr = R({
2877
2913
  }),
2878
2914
  build(e) {
2879
2915
  return async (t, n) => {
2880
- if ((e.request || e.remove_request) && ur(t, (t) => {
2916
+ if ((e.request || e.remove_request) && dr(t, (t) => {
2881
2917
  if (e.remove_request?.forEach((e) => t.delete(e)), e.request) for (let [n, r] of Object.entries(e.request)) t.set(n, r);
2882
2918
  }), 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);
2883
2919
  };
2884
2920
  }
2885
- }), vr = R({
2921
+ }), yr = z({
2886
2922
  type: "cache",
2887
2923
  optionsSchema: e.object({ ttl_seconds: e.number().int().positive() }),
2888
2924
  build(e) {
@@ -2893,7 +2929,7 @@ var gr = R({
2893
2929
  }
2894
2930
  };
2895
2931
  }
2896
- }), yr = [
2932
+ }), br = [
2897
2933
  "173.245.48.0/20",
2898
2934
  "103.21.244.0/22",
2899
2935
  "103.22.200.0/22",
@@ -2917,7 +2953,7 @@ var gr = R({
2917
2953
  "2a06:98c0::/29",
2918
2954
  "2c0f:f248::/32"
2919
2955
  ];
2920
- function br(e) {
2956
+ function xr(e) {
2921
2957
  let t = e.split(".");
2922
2958
  if (t.length !== 4) return null;
2923
2959
  let n = [];
@@ -2929,14 +2965,14 @@ function br(e) {
2929
2965
  }
2930
2966
  return n;
2931
2967
  }
2932
- function xr(e) {
2968
+ function Sr(e) {
2933
2969
  if (e === "") return [];
2934
2970
  let t = e.split(":"), n = [];
2935
2971
  for (let e = 0; e < t.length; e++) {
2936
2972
  let r = t[e];
2937
2973
  if (r.includes(".")) {
2938
2974
  if (e !== t.length - 1) return null;
2939
- let i = br(r);
2975
+ let i = xr(r);
2940
2976
  if (!i) return null;
2941
2977
  n.push(i[0] << 8 | i[1], i[2] << 8 | i[3]);
2942
2978
  continue;
@@ -2946,14 +2982,14 @@ function xr(e) {
2946
2982
  }
2947
2983
  return n;
2948
2984
  }
2949
- function Sr(e) {
2985
+ function Cr(e) {
2950
2986
  let t = e.split("::");
2951
2987
  if (t.length > 2) return null;
2952
- let n = xr(t[0] ?? "");
2988
+ let n = Sr(t[0] ?? "");
2953
2989
  if (!n) return null;
2954
2990
  let r;
2955
2991
  if (t.length === 2) {
2956
- let e = xr(t[1] ?? "");
2992
+ let e = Sr(t[1] ?? "");
2957
2993
  if (!e) return null;
2958
2994
  let i = 8 - n.length - e.length;
2959
2995
  if (i < 1) return null;
@@ -2968,25 +3004,25 @@ function Sr(e) {
2968
3004
  for (let e of r) i.push(e >> 8 & 255, e & 255);
2969
3005
  return i;
2970
3006
  }
2971
- function Cr(e) {
3007
+ function wr(e) {
2972
3008
  let t = e.trim();
2973
3009
  t.startsWith("[") && t.endsWith("]") && (t = t.slice(1, -1));
2974
3010
  let n = t.indexOf("%");
2975
3011
  if (n !== -1 && (t = t.slice(0, n)), t === "") return null;
2976
- if (!t.includes(":")) return br(t);
2977
- let r = Sr(t);
3012
+ if (!t.includes(":")) return xr(t);
3013
+ let r = Cr(t);
2978
3014
  return r ? r.slice(0, 10).every((e) => e === 0) && r[10] === 255 && r[11] === 255 ? r.slice(12) : r : null;
2979
3015
  }
2980
- function wr(e) {
2981
- let [t, n] = e.split("/"), r = Cr(t ?? ""), i = Number(n);
3016
+ function Tr(e) {
3017
+ let [t, n] = e.split("/"), r = wr(t ?? ""), i = Number(n);
2982
3018
  if (!r || !Number.isInteger(i)) throw Error(`Invalid Cloudflare CIDR: ${e}`);
2983
3019
  return {
2984
3020
  bytes: r,
2985
3021
  prefixBits: i
2986
3022
  };
2987
3023
  }
2988
- var Tr = yr.map(wr);
2989
- function Er(e, t) {
3024
+ var Er = br.map(Tr);
3025
+ function Dr(e, t) {
2990
3026
  if (e.length !== t.bytes.length) return !1;
2991
3027
  let n = t.prefixBits >> 3;
2992
3028
  for (let r = 0; r < n; r++) if (e[r] !== t.bytes[r]) return !1;
@@ -2995,11 +3031,11 @@ function Er(e, t) {
2995
3031
  let i = 255 << 8 - r & 255;
2996
3032
  return (e[n] & i) === (t.bytes[n] & i);
2997
3033
  }
2998
- function Dr(e) {
2999
- let t = Cr(e);
3000
- return t ? Tr.some((e) => Er(t, e)) : !1;
3034
+ function Or(e) {
3035
+ let t = wr(e);
3036
+ return t ? Er.some((e) => Dr(t, e)) : !1;
3001
3037
  }
3002
- var Or = R({
3038
+ var kr = z({
3003
3039
  type: "forwarded_headers",
3004
3040
  optionsSchema: e.object({
3005
3041
  client_ip_header: e.string().default("cf-connecting-ip"),
@@ -3010,40 +3046,40 @@ var Or = R({
3010
3046
  build(e) {
3011
3047
  return async (t, n) => {
3012
3048
  let r = new URL(t.req.url);
3013
- ur(t, (n) => {
3049
+ dr(t, (n) => {
3014
3050
  n.set("x-forwarded-host", r.host), n.set("x-forwarded-proto", r.protocol.replace(":", "")), e.set_x_original_url && n.set("x-original-url", t.req.url);
3015
- let i = n.get(e.client_ip_header), a = i && e.skip_cloudflare_client_ip && Dr(i) ? null : i, o = (n.get("x-forwarded-for") ?? "").split(",").map((e) => e.trim()).filter(Boolean), s = a ?? o[o.length - 1] ?? "127.0.0.1", c = o.length === 0 || o[o.length - 1] !== s, l = o.length ? c ? `${o.join(", ")}, ${s}` : o.join(", ") : s;
3051
+ let i = n.get(e.client_ip_header), a = i && e.skip_cloudflare_client_ip && Or(i) ? null : i, o = (n.get("x-forwarded-for") ?? "").split(",").map((e) => e.trim()).filter(Boolean), s = a ?? o[o.length - 1] ?? "127.0.0.1", c = o.length === 0 || o[o.length - 1] !== s, l = o.length ? c ? `${o.join(", ")}, ${s}` : o.join(", ") : s;
3016
3052
  n.set("x-forwarded-for", l), e.set_x_real_ip && n.set("x-real-ip", s);
3017
3053
  }), await n();
3018
3054
  };
3019
3055
  }
3020
- }), kr = e.object({ upstream_host: e.string().optional() });
3021
- function Ar(e) {
3056
+ }), Ar = e.object({ upstream_host: e.string().optional() });
3057
+ function jr(e) {
3022
3058
  return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
3023
3059
  }
3024
- function jr(e) {
3060
+ function Mr(e) {
3025
3061
  if (typeof e.getSetCookie == "function") return e.getSetCookie();
3026
3062
  let t = [];
3027
3063
  return e.forEach((e, n) => {
3028
3064
  n.toLowerCase() === "set-cookie" && t.push(e);
3029
3065
  }), t;
3030
3066
  }
3031
- var Mr = R({
3067
+ var Nr = z({
3032
3068
  type: "rewrite_cookies",
3033
- optionsSchema: kr,
3069
+ optionsSchema: Ar,
3034
3070
  build(e) {
3035
3071
  return async (t, n) => {
3036
3072
  await n();
3037
3073
  let r = new URL(t.req.url).hostname, i = e.upstream_host ?? t.get("__proxy_upstream_host__");
3038
3074
  if (!i) return;
3039
- let a = jr(t.res.headers);
3075
+ let a = Mr(t.res.headers);
3040
3076
  if (a.length === 0) return;
3041
- let o = Ar(i), s = RegExp(`(?:^|;\\s*)Domain=\\.?${o}(?=;|$)`, "i");
3077
+ let o = jr(i), s = RegExp(`(?:^|;\\s*)Domain=\\.?${o}(?=;|$)`, "i");
3042
3078
  W(t), t.res.headers.delete("set-cookie");
3043
3079
  for (let e of a) t.res.headers.append("set-cookie", e.replace(s, `Domain=${r}`));
3044
3080
  };
3045
3081
  }
3046
- }), Nr = R({
3082
+ }), Pr = z({
3047
3083
  type: "rewrite_location",
3048
3084
  optionsSchema: e.object({ upstream_origin: e.string().optional() }),
3049
3085
  build(e) {
@@ -3069,14 +3105,14 @@ var Mr = R({
3069
3105
  W(t), t.res.headers.set("location", c);
3070
3106
  };
3071
3107
  }
3072
- }), Pr = class extends Error {
3108
+ }), Fr = class extends Error {
3073
3109
  ms;
3074
3110
  constructor(e, t) {
3075
3111
  super(`${t ?? "Operation"} timed out after ${e}ms`), this.name = "TimeoutError", this.ms = e;
3076
3112
  }
3077
3113
  };
3078
3114
  function G(e) {
3079
- return e instanceof Pr ? !0 : e instanceof Error ? e.name === "AbortError" || e.name === "TimeoutError" : !1;
3115
+ return e instanceof Fr ? !0 : e instanceof Error ? e.name === "AbortError" || e.name === "TimeoutError" : !1;
3080
3116
  }
3081
3117
  function K(e, t) {
3082
3118
  let n = new AbortController(), r = setTimeout(() => n.abort(), e);
@@ -3084,7 +3120,7 @@ function K(e, t) {
3084
3120
  }
3085
3121
  function q(e, t, n) {
3086
3122
  let r, i = new Promise((e, i) => {
3087
- r = setTimeout(() => i(new Pr(t, n)), t);
3123
+ r = setTimeout(() => i(new Fr(t, n)), t);
3088
3124
  });
3089
3125
  return Promise.race([e, i]).finally(() => {
3090
3126
  r && clearTimeout(r);
@@ -3092,7 +3128,7 @@ function q(e, t, n) {
3092
3128
  }
3093
3129
  //#endregion
3094
3130
  //#region src/data-plane/handlers/http.ts
3095
- var Fr = new Set([
3131
+ var Ir = new Set([
3096
3132
  "connection",
3097
3133
  "keep-alive",
3098
3134
  "proxy-authenticate",
@@ -3101,24 +3137,24 @@ var Fr = new Set([
3101
3137
  "trailers",
3102
3138
  "transfer-encoding",
3103
3139
  "upgrade"
3104
- ]), Ir = 3e4, Lr = e.object({
3140
+ ]), Lr = 3e4, Rr = e.object({
3105
3141
  upstream_url: e.string(),
3106
3142
  preserve_host: e.boolean().default(!1),
3107
3143
  timeout_ms: e.number().int().positive().optional()
3108
3144
  });
3109
- function Rr(e, t) {
3145
+ function zr(e, t) {
3110
3146
  return e === "" || e === "/" ? t : `${e.endsWith("/") ? e.slice(0, -1) : e}${t.startsWith("/") ? t : `/${t}`}`;
3111
3147
  }
3112
- function zr(e) {
3148
+ function Br(e) {
3113
3149
  return e !== "GET" && e !== "HEAD";
3114
3150
  }
3115
- function Br(e, t) {
3151
+ function Vr(e, t) {
3116
3152
  let n = new URL(t.url), r = new URL(e.upstream_url);
3117
- r.pathname = Rr(r.pathname, n.pathname), r.search = n.search;
3153
+ r.pathname = zr(r.pathname, n.pathname), r.search = n.search;
3118
3154
  let i = new Headers(t.headers);
3119
- for (let e of Fr) i.delete(e);
3155
+ for (let e of Ir) i.delete(e);
3120
3156
  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(":", ""));
3121
- let a = zr(t.method) ? t.body : void 0, o = {
3157
+ let a = Br(t.method) ? t.body : void 0, o = {
3122
3158
  method: t.method,
3123
3159
  headers: i,
3124
3160
  body: a,
@@ -3129,13 +3165,13 @@ function Br(e, t) {
3129
3165
  init: o
3130
3166
  };
3131
3167
  }
3132
- var Vr = R({
3168
+ var Hr = z({
3133
3169
  type: "http",
3134
- optionsSchema: Lr,
3170
+ optionsSchema: Rr,
3135
3171
  build(e) {
3136
- let t = e.timeout_ms ?? Ir;
3172
+ let t = e.timeout_ms ?? Lr;
3137
3173
  return async (n) => {
3138
- let { target: r, init: i } = Br(e, U(n));
3174
+ let { target: r, init: i } = Vr(e, U(n));
3139
3175
  n.set("__proxy_upstream_host__", r.hostname), n.set("__proxy_upstream_origin__", `${r.protocol}//${r.host}`);
3140
3176
  try {
3141
3177
  return await K(t, (e) => fetch(r.toString(), {
@@ -3147,24 +3183,24 @@ var Vr = R({
3147
3183
  }
3148
3184
  };
3149
3185
  }
3150
- }), Hr = 3e4, Ur = e.object({
3186
+ }), Ur = 3e4, Wr = e.object({
3151
3187
  binding: e.string(),
3152
3188
  upstream_url: e.string().optional(),
3153
3189
  preserve_host: e.boolean().default(!0),
3154
3190
  timeout_ms: e.number().int().positive().optional()
3155
3191
  });
3156
- function Wr(e) {
3192
+ function Gr(e) {
3157
3193
  return typeof e == "object" && !!e && typeof e.fetch == "function";
3158
3194
  }
3159
- var Gr = R({
3195
+ var Kr = z({
3160
3196
  type: "service_binding",
3161
- optionsSchema: Ur,
3197
+ optionsSchema: Wr,
3162
3198
  build(e, t) {
3163
3199
  let n = t.bindings[e.binding];
3164
- if (!Wr(n)) throw Error(`Service binding "${e.binding}" is not configured or is not a Fetcher`);
3165
- let r = e.upstream_url ?? `https://${e.binding}.binding.invalid/`, i = e.timeout_ms ?? Hr;
3200
+ if (!Gr(n)) throw Error(`Service binding "${e.binding}" is not configured or is not a Fetcher`);
3201
+ let r = e.upstream_url ?? `https://${e.binding}.binding.invalid/`, i = e.timeout_ms ?? Ur;
3166
3202
  return async (t) => {
3167
- let a = U(t), { target: o, init: s } = Br({
3203
+ let a = U(t), { target: o, init: s } = Vr({
3168
3204
  upstream_url: r,
3169
3205
  preserve_host: e.preserve_host
3170
3206
  }, a);
@@ -3179,34 +3215,34 @@ var Gr = R({
3179
3215
  }
3180
3216
  };
3181
3217
  }
3182
- }), Kr = 3e4, qr = e.object({
3218
+ }), qr = 3e4, Jr = e.object({
3183
3219
  binding: e.string(),
3184
3220
  script_name: e.string(),
3185
3221
  cpu_ms: e.number().int().positive().optional(),
3186
3222
  subrequests: e.number().int().positive().optional(),
3187
3223
  timeout_ms: e.number().int().positive().optional()
3188
3224
  });
3189
- function Jr(e) {
3225
+ function Yr(e) {
3190
3226
  return typeof e == "object" && !!e && typeof e.get == "function";
3191
3227
  }
3192
3228
  var J = /\{(tenant_id|custom_domain_id|domain|host)\}/g;
3193
- function Yr(e) {
3229
+ function Xr(e) {
3194
3230
  return J.lastIndex = 0, J.test(e);
3195
3231
  }
3196
- var Xr = R({
3232
+ var Zr = z({
3197
3233
  type: "dispatch_namespace",
3198
- optionsSchema: qr,
3234
+ optionsSchema: Jr,
3199
3235
  build(e, t) {
3200
3236
  let n = t.bindings[e.binding];
3201
- if (!Jr(n)) throw Error(`Dispatch namespace binding "${e.binding}" is not configured or does not expose .get()`);
3202
- let r = Yr(e.script_name), i = e.timeout_ms ?? Kr, a = e.cpu_ms || e.subrequests ? { limits: {
3237
+ if (!Yr(n)) throw Error(`Dispatch namespace binding "${e.binding}" is not configured or does not expose .get()`);
3238
+ let r = Xr(e.script_name), i = e.timeout_ms ?? qr, a = e.cpu_ms || e.subrequests ? { limits: {
3203
3239
  ...e.cpu_ms ? { cpuMs: e.cpu_ms } : {},
3204
3240
  ...e.subrequests ? { subrequests: e.subrequests } : {}
3205
3241
  } } : void 0;
3206
3242
  return async (t) => {
3207
3243
  let o = e.script_name;
3208
3244
  if (r) {
3209
- let n = sr(t), r = cr(t), i = lr(t), a = t.req.header("host") ?? t.req.header("x-forwarded-host") ?? "";
3245
+ let n = cr(t), r = lr(t), i = ur(t), a = t.req.header("host") ?? t.req.header("x-forwarded-host") ?? "";
3210
3246
  if (o = o.replace(J, (e, t) => {
3211
3247
  switch (t) {
3212
3248
  case "tenant_id": return n ?? "";
@@ -3229,7 +3265,7 @@ var Xr = R({
3229
3265
  }
3230
3266
  };
3231
3267
  }
3232
- }), Zr = R({
3268
+ }), Qr = z({
3233
3269
  type: "redirect",
3234
3270
  optionsSchema: e.object({
3235
3271
  upstream_url: e.string().refine((e) => {
@@ -3258,7 +3294,7 @@ var Xr = R({
3258
3294
  });
3259
3295
  };
3260
3296
  }
3261
- }), Qr = R({
3297
+ }), $r = z({
3262
3298
  type: "static",
3263
3299
  optionsSchema: e.object({
3264
3300
  status: e.number().int().default(200),
@@ -3278,15 +3314,15 @@ var Xr = R({
3278
3314
  });
3279
3315
  //#endregion
3280
3316
  //#region src/data-plane/handlers/index.ts
3281
- function $r(e) {
3282
- e.add(pr).add(gr).add(_r).add(vr).add(Or).add(Mr).add(Nr).add(Vr).add(Gr).add(Xr).add(Zr).add(Qr);
3317
+ function ei(e) {
3318
+ e.add(mr).add(_r).add(vr).add(yr).add(kr).add(Nr).add(Pr).add(Hr).add(Kr).add(Zr).add(Qr).add($r);
3283
3319
  }
3284
3320
  //#endregion
3285
3321
  //#region src/data-plane/matcher.ts
3286
- function ei(e) {
3322
+ function ti(e) {
3287
3323
  return [...e].sort((e, t) => e.priority === t.priority ? e.created_at.localeCompare(t.created_at) : e.priority - t.priority);
3288
3324
  }
3289
- function ti(e, t) {
3325
+ function ni(e, t) {
3290
3326
  let n = e.toLowerCase(), r = t.toLowerCase();
3291
3327
  if (n === r) return !0;
3292
3328
  if (n.startsWith("*.")) {
@@ -3295,13 +3331,13 @@ function ti(e, t) {
3295
3331
  }
3296
3332
  return !1;
3297
3333
  }
3298
- function ni(e, t) {
3299
- return !e || e.length === 0 ? !0 : e.some((e) => ti(e, t));
3334
+ function ri(e, t) {
3335
+ return !e || e.length === 0 ? !0 : e.some((e) => ni(e, t));
3300
3336
  }
3301
- function ri(e) {
3337
+ function ii(e) {
3302
3338
  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;
3303
3339
  return async (e, i) => {
3304
- if (r && !ni(r, e.req.header("host") ?? "")) return new Response("No matching route", { status: 404 });
3340
+ if (r && !ri(r, e.req.header("host") ?? "")) return new Response("No matching route", { status: 404 });
3305
3341
  for (let [n, r] of t) {
3306
3342
  let t = e.req.header(n);
3307
3343
  if (t === void 0 || !r.test(t)) return new Response("No matching route", { status: 404 });
@@ -3318,17 +3354,17 @@ function ri(e) {
3318
3354
  }
3319
3355
  //#endregion
3320
3356
  //#region src/data-plane/compile.ts
3321
- var ii = "forwarded_headers";
3322
- function Y(e) {
3357
+ var Y = "forwarded_headers";
3358
+ function ai(e) {
3323
3359
  return e.some((e) => e.type === "forwarded_headers") ? [...e] : [{
3324
- type: ii,
3360
+ type: Y,
3325
3361
  options: {}
3326
3362
  }, ...e];
3327
3363
  }
3328
3364
  function X(e, t) {
3329
- return e.has("forwarded_headers") ? Y(t) : [...t];
3365
+ return e.has("forwarded_headers") ? ai(t) : [...t];
3330
3366
  }
3331
- var ai = [
3367
+ var oi = [
3332
3368
  "GET",
3333
3369
  "POST",
3334
3370
  "PUT",
@@ -3340,34 +3376,34 @@ var ai = [
3340
3376
  function Z(e, n, r, i) {
3341
3377
  let a = new t();
3342
3378
  r && a.use("*", async (e, t) => {
3343
- or(e, r), await t();
3379
+ sr(e, r), await t();
3344
3380
  });
3345
- let o = ei(e);
3381
+ let o = ti(e);
3346
3382
  for (let e of o) {
3347
3383
  let t = [];
3348
- t.push(ri(e.match));
3384
+ t.push(ii(e.match));
3349
3385
  for (let r of X(n, e.handlers)) t.push(n.build(r.type, r.options));
3350
- let r = e.match.methods?.length ? e.match.methods.map((e) => e.toUpperCase()) : ai, i = e.match.path || "/*";
3386
+ let r = e.match.methods?.length ? e.match.methods.map((e) => e.toUpperCase()) : oi, i = e.match.path || "/*";
3351
3387
  a.on(r, [i], ...t);
3352
3388
  }
3353
- return i && i.length > 0 ? a.on(ai, ["*"], ...i) : a.all("*", (e) => e.text("No matching route", 404)), a.onError((e, t) => {
3389
+ return i && i.length > 0 ? a.on(oi, ["*"], ...i) : a.all("*", (e) => e.text("No matching route", 404)), a.onError((e, t) => {
3354
3390
  let n = G(e);
3355
3391
  return t.text(n ? "Upstream timeout" : "Bad gateway", n ? 504 : 502, { "x-authhero-proxy-error": n ? "handler_timeout" : "handler_failed" });
3356
3392
  }), a;
3357
3393
  }
3358
3394
  //#endregion
3359
3395
  //#region src/data-plane/router.ts
3360
- var oi = 1e4;
3361
- function si(e) {
3362
- return e.resolver ? e.resolver : e.cache ? I(e.data, e.cache) : I(e.data, e.cacheTtlMs ?? 3e4);
3363
- }
3396
+ var si = 1e4;
3364
3397
  function ci(e) {
3398
+ return e.resolver ? e.resolver : e.cache ? L(e.data, e.cache) : L(e.data, e.cacheTtlMs ?? 3e4);
3399
+ }
3400
+ function li(e) {
3365
3401
  if (e.registry) return e.registry;
3366
- let t = new L(e.bindings ?? {});
3367
- return $r(t), t;
3402
+ let t = new R(e.bindings ?? {});
3403
+ return ei(t), t;
3368
3404
  }
3369
3405
  function Q(e) {
3370
- let t = si(e), n = ci(e), r = /* @__PURE__ */ new WeakMap(), i = e.resolveHostTimeoutMs ?? oi, a = e.defaultHandlers && e.defaultHandlers.length > 0 ? X(n, e.defaultHandlers).map((e) => n.build(e.type, e.options)) : void 0, o = a ? Z([], n, void 0, a) : void 0;
3406
+ let t = ci(e), n = li(e), r = /* @__PURE__ */ new WeakMap(), i = e.resolveHostTimeoutMs ?? si, a = e.defaultHandlers && e.defaultHandlers.length > 0 ? X(n, e.defaultHandlers).map((e) => n.build(e.type, e.options)) : void 0, o = a ? Z([], n, void 0, a) : void 0;
3371
3407
  return async (e) => {
3372
3408
  let s = e.req.header("host") ?? e.req.header("x-forwarded-host");
3373
3409
  if (!s) return e.text("Missing host", 400);
@@ -3385,13 +3421,13 @@ function Q(e) {
3385
3421
  }
3386
3422
  };
3387
3423
  }
3388
- function li(e) {
3424
+ function ui(e) {
3389
3425
  let n = new t();
3390
3426
  return n.all("*", Q(e)), n;
3391
3427
  }
3392
3428
  //#endregion
3393
3429
  //#region src/app.ts
3394
- function ui(e) {
3430
+ function di(e) {
3395
3431
  let n = new t();
3396
3432
  return n.all("*", Q({
3397
3433
  data: e.data,
@@ -3409,17 +3445,17 @@ function ui(e) {
3409
3445
  }
3410
3446
  //#endregion
3411
3447
  //#region src/data-plane/cache-api-cache.ts
3412
- var di = 1e3, fi = 1e3;
3413
- function pi(e, t) {
3448
+ var fi = 1e3, pi = 1e3;
3449
+ function mi(e, t) {
3414
3450
  return new Request(`https://proxy-cache.internal/${encodeURIComponent(e)}/hosts/${encodeURIComponent(t.toLowerCase())}`, { method: "GET" });
3415
3451
  }
3416
- function mi() {
3452
+ function hi() {
3417
3453
  return globalThis.caches?.default;
3418
3454
  }
3419
- function hi(e) {
3420
- let t = e.cache ?? mi();
3455
+ function gi(e) {
3456
+ let t = e.cache ?? hi();
3421
3457
  if (!t) return e.upstream;
3422
- let n = t, r = e.namespace ?? "authhero-proxy", i = e.cacheTtlSeconds ?? 60, a = e.negativeCacheTtlSeconds ?? 10, o = e.waitUntil, s = e.cacheReadTimeoutMs ?? di, c = e.cacheWriteTimeoutMs ?? fi;
3458
+ let n = t, r = e.namespace ?? "authhero-proxy", i = e.cacheTtlSeconds ?? 60, a = e.negativeCacheTtlSeconds ?? 10, o = e.waitUntil, s = e.cacheReadTimeoutMs ?? fi, c = e.cacheWriteTimeoutMs ?? pi;
3423
3459
  async function l(e) {
3424
3460
  try {
3425
3461
  return await q(Promise.resolve(n.match(e)), s, "cache.match");
@@ -3428,7 +3464,7 @@ function hi(e) {
3428
3464
  }
3429
3465
  }
3430
3466
  return { async resolveHost(t) {
3431
- let s = pi(r, t), u = await l(s);
3467
+ let s = mi(r, t), u = await l(s);
3432
3468
  if (u) try {
3433
3469
  return (await u.json()).value;
3434
3470
  } catch {}
@@ -3439,14 +3475,14 @@ function hi(e) {
3439
3475
  return o ? o(m) : await m, d;
3440
3476
  } };
3441
3477
  }
3442
- function gi(e, t) {
3443
- return pi(e, t);
3478
+ function _i(e, t) {
3479
+ return mi(e, t);
3444
3480
  }
3445
3481
  //#endregion
3446
3482
  //#region src/data-plane/cache-adapter-cache.ts
3447
- var _i = 1e3, vi = 1e3;
3448
- function yi(e) {
3449
- 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 = _i, cacheWriteTimeoutMs: u = vi } = e, d = /* @__PURE__ */ new Map();
3483
+ var vi = 1e3, yi = 1e3;
3484
+ function bi(e) {
3485
+ 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 = vi, cacheWriteTimeoutMs: u = yi } = e, d = /* @__PURE__ */ new Map();
3450
3486
  function f(e) {
3451
3487
  return `${s}:${e.toLowerCase()}`;
3452
3488
  }
@@ -3499,7 +3535,7 @@ function yi(e) {
3499
3535
  }
3500
3536
  } };
3501
3537
  }
3502
- function bi(e, t) {
3538
+ function xi(e, t) {
3503
3539
  return `${e}:${t.toLowerCase()}`;
3504
3540
  }
3505
3541
  //#endregion
@@ -3507,7 +3543,7 @@ function bi(e, t) {
3507
3543
  function $() {
3508
3544
  throw Error("Static proxy adapter is read-only; configure routes at init time");
3509
3545
  }
3510
- function xi(e, t, n, r, i, a) {
3546
+ function Si(e, t, n, r, i, a) {
3511
3547
  return {
3512
3548
  id: e.id ?? `${n}:${t}`,
3513
3549
  tenant_id: r,
@@ -3522,10 +3558,10 @@ function xi(e, t, n, r, i, a) {
3522
3558
  updated_at: e.updated_at ?? a
3523
3559
  };
3524
3560
  }
3525
- function Si(e) {
3561
+ function Ci(e) {
3526
3562
  let t = (/* @__PURE__ */ new Date()).toISOString(), n = e.defaultTenantId ?? "static", r = /* @__PURE__ */ new Map();
3527
3563
  for (let [i, a] of Object.entries(e.hosts)) {
3528
- 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) => xi(n, r, e, s, c, t)).sort((e, t) => e.priority - t.priority);
3564
+ 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) => Si(n, r, e, s, c, t)).sort((e, t) => e.priority - t.priority);
3529
3565
  r.set(e, {
3530
3566
  tenant_id: s,
3531
3567
  custom_domain_id: c,
@@ -3569,7 +3605,7 @@ function Si(e) {
3569
3605
  }
3570
3606
  };
3571
3607
  }
3572
- function Ci(e, t = {}) {
3608
+ function wi(e, t = {}) {
3573
3609
  return {
3574
3610
  priority: t.priority,
3575
3611
  match: { path: t.path ?? "/*" },
@@ -3584,10 +3620,10 @@ function Ci(e, t = {}) {
3584
3620
  }
3585
3621
  //#endregion
3586
3622
  //#region src/constants.ts
3587
- var wi = "proxy:resolve_host";
3623
+ var Ti = "proxy:resolve_host";
3588
3624
  //#endregion
3589
3625
  //#region src/http-adapter/index.ts
3590
- function Ti() {
3626
+ function Ei() {
3591
3627
  let e = () => {
3592
3628
  throw Error("HTTP proxy adapter does not expose write access to proxy_routes; mutate via the control-plane management API");
3593
3629
  };
@@ -3609,7 +3645,7 @@ function Ti() {
3609
3645
  }
3610
3646
  };
3611
3647
  }
3612
- function Ei(e) {
3648
+ function Di(e) {
3613
3649
  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;
3614
3650
  function c(e) {
3615
3651
  let t = new AbortController(), n = setTimeout(() => t.abort(), s);
@@ -3642,7 +3678,7 @@ function Ei(e) {
3642
3678
  }), u);
3643
3679
  }
3644
3680
  return {
3645
- proxyRoutes: Ti(),
3681
+ proxyRoutes: Ei(),
3646
3682
  async resolveHost(e) {
3647
3683
  let i = await f(), a = `${n}${r}${encodeURIComponent(e.toLowerCase())}`, o = await c((e) => t(a, {
3648
3684
  headers: { authorization: `Bearer ${i}` },
@@ -3656,7 +3692,7 @@ function Ei(e) {
3656
3692
  }
3657
3693
  //#endregion
3658
3694
  //#region src/http-adapter/service-binding-fetch.ts
3659
- function Di(e) {
3695
+ function Oi(e) {
3660
3696
  return (t, n) => {
3661
3697
  let r = t instanceof Request && n === void 0 ? t : new Request(t, n);
3662
3698
  return e.fetch(r);
@@ -3664,11 +3700,11 @@ function Di(e) {
3664
3700
  }
3665
3701
  //#endregion
3666
3702
  //#region src/kv-adapter/index.ts
3667
- var Oi = "authhero-proxy-host:";
3668
- function ki(e, t) {
3703
+ var ki = "authhero-proxy-host:";
3704
+ function Ai(e, t) {
3669
3705
  return `${e}${t.toLowerCase()}`;
3670
3706
  }
3671
- function Ai() {
3707
+ function ji() {
3672
3708
  let e = () => {
3673
3709
  throw Error("KV proxy adapter does not expose write access to proxy_routes; mutate via the control-plane management API");
3674
3710
  };
@@ -3690,15 +3726,15 @@ function Ai() {
3690
3726
  }
3691
3727
  };
3692
3728
  }
3693
- function ji(e) {
3694
- let { kv: t, keyPrefix: n = Oi, timeoutMs: r } = e;
3729
+ function Mi(e) {
3730
+ let { kv: t, keyPrefix: n = ki, timeoutMs: r } = e;
3695
3731
  return {
3696
- proxyRoutes: Ai(),
3732
+ proxyRoutes: ji(),
3697
3733
  async resolveHost(e) {
3698
- let i = ki(n, e), a = t.get(i, "json");
3734
+ let i = Ai(n, e), a = t.get(i, "json");
3699
3735
  return (r && r > 0 ? await q(a, r, "kv.get") : await a) ?? null;
3700
3736
  }
3701
3737
  };
3702
3738
  }
3703
3739
  //#endregion
3704
- export { Oi as DEFAULT_KV_HOST_KEY_PREFIX, ii as FORWARDED_HEADERS_HANDLER_TYPE, L as HandlerRegistry, wi as PROXY_RESOLVE_HOST_SCOPE, gr as basicAuthHandler, bi as buildCacheAdapterKey, gi as buildCacheApiKey, ki as buildKvHostKey, ri as buildMatchFilter, vr as cacheHandler, Z as compileHostApp, pr as corsHandler, yi as createCacheAdapterHostCache, hi as createCacheApiHostCache, Ei as createHttpProxyAdapter, I as createInMemoryHostCache, ji as createKvProxyAdapter, ui as createProxyApp, Q as createProxyDataPlaneHandler, li as createProxyDataPlaneRouter, Di as createServiceBindingFetch, Si as createStaticProxyAdapter, R as defineHandler, Xr as dispatchNamespaceHandler, Or as forwardedHeadersHandler, On as handlerConfigSchema, _r as headersHandler, Vr as httpHandler, Ci as httpRoute, Dr as isCloudflareIp, Dn as matchSchema, ni as matchesAnyHost, ti as matchesHost, P as proxyRouteInsertSchema, kn as proxyRouteSchema, An as proxyRouteUpdateSchema, Zr as redirectHandler, $r as registerBuiltinHandlers, Mr as rewriteCookiesHandler, Nr as rewriteLocationHandler, Gr as serviceBindingHandler, ei as sortRoutes, Qr as staticHandler, Y as withForwardedHeaders, X as withForwardedHeadersFor };
3740
+ export { ki as DEFAULT_KV_HOST_KEY_PREFIX, Y as FORWARDED_HEADERS_HANDLER_TYPE, R as HandlerRegistry, Ti as PROXY_RESOLVE_HOST_SCOPE, _r as basicAuthHandler, xi as buildCacheAdapterKey, _i as buildCacheApiKey, Ai as buildKvHostKey, ii as buildMatchFilter, yr as cacheHandler, Z as compileHostApp, mr as corsHandler, bi as createCacheAdapterHostCache, gi as createCacheApiHostCache, Di as createHttpProxyAdapter, L as createInMemoryHostCache, Mi as createKvProxyAdapter, di as createProxyApp, Q as createProxyDataPlaneHandler, ui as createProxyDataPlaneRouter, Oi as createServiceBindingFetch, Ci as createStaticProxyAdapter, z as defineHandler, Zr as dispatchNamespaceHandler, kr as forwardedHeadersHandler, On as handlerConfigSchema, vr as headersHandler, Hr as httpHandler, wi as httpRoute, Or as isCloudflareIp, Dn as matchSchema, ri as matchesAnyHost, ni as matchesHost, F as proxyRouteInsertSchema, kn as proxyRouteSchema, An as proxyRouteUpdateSchema, Qr as redirectHandler, ei as registerBuiltinHandlers, Nr as rewriteCookiesHandler, Pr as rewriteLocationHandler, Kr as serviceBindingHandler, ti as sortRoutes, $r as staticHandler, ai as withForwardedHeaders, X as withForwardedHeadersFor };