@authhero/cloudflare-adapter 2.37.2 → 2.37.4

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.
@@ -685,14 +685,39 @@ function ue(e) {
685
685
  //#endregion
686
686
  //#region src/analytics-engine-logs/list.ts
687
687
  function de(e) {
688
- let t = {}, n = /(\w+):(?:"([^"]*)"|(\S+))/g, r;
689
- for (; (r = n.exec(e)) !== null;) {
690
- let e = r[1], n = r[2] === void 0 ? r[3] : r[2];
691
- !e || n === void 0 || (t[e] || (t[e] = []), t[e].push(n));
688
+ return e.replace(/\\([\\"+\-!(){}[\]^~*?:/&|])/g, "$1");
689
+ }
690
+ function fe(e) {
691
+ let t = [], n = "", r = !1;
692
+ for (let i = 0; i < e.length; i++) {
693
+ let a = e[i];
694
+ a === "\"" ? (r = !r, n += a) : a === " " && !r ? (n.trim() && t.push(n.trim()), n = "") : n += a;
692
695
  }
693
- return t;
696
+ return n.trim() && t.push(n.trim()), t;
694
697
  }
695
698
  function M(e) {
699
+ let t = e;
700
+ return t.startsWith("\"") && t.endsWith("\"") && t.length > 1 && (t = t.slice(1, -1)), de(t);
701
+ }
702
+ function pe(e) {
703
+ let t = {}, n = [];
704
+ for (let r of fe(e)) {
705
+ if (r === "OR" || r === "AND") continue;
706
+ let e = r.match(/^(\w+):([\s\S]*)$/);
707
+ if (e) {
708
+ let n = e[1], r = M(e[2]);
709
+ t[n] || (t[n] = []), t[n].push(r);
710
+ } else {
711
+ let e = M(r);
712
+ e && n.push(e);
713
+ }
714
+ }
715
+ return {
716
+ fields: t,
717
+ terms: n
718
+ };
719
+ }
720
+ function N(e) {
696
721
  return {
697
722
  log_id: "blob1",
698
723
  tenant_id: "blob2",
@@ -713,7 +738,7 @@ function M(e) {
713
738
  hostname: "blob17"
714
739
  }[e] || null;
715
740
  }
716
- function fe(e) {
741
+ function me(e) {
717
742
  let t = [];
718
743
  for (let [n, r] of Object.entries(e)) {
719
744
  let e = r.filter((e) => e !== "");
@@ -724,7 +749,7 @@ function fe(e) {
724
749
  n.length > 0 && t.push(`(${n.join(" OR ")})`);
725
750
  continue;
726
751
  }
727
- let i = M(n);
752
+ let i = N(n);
728
753
  if (i) if (e.length === 1) t.push(`${i} = ${k(e[0])}`);
729
754
  else {
730
755
  let n = e.map((e) => k(e)).join(", ");
@@ -733,19 +758,25 @@ function fe(e) {
733
758
  }
734
759
  return t;
735
760
  }
736
- function pe(e) {
737
- return e === "date" ? "double2" : M(e) || "timestamp";
761
+ function he(e) {
762
+ return e.filter((e) => e !== "").map((e) => {
763
+ let t = k(e), n = k(`%${e}%`);
764
+ return `(blob7 = ${t} OR blob5 LIKE ${n} OR blob4 LIKE ${n})`;
765
+ });
738
766
  }
739
- function me(e) {
767
+ function ge(e) {
768
+ return e === "date" ? "double2" : N(e) || "timestamp";
769
+ }
770
+ function P(e) {
740
771
  return async (t, n = {}) => {
741
772
  let { page: r = 0, per_page: i = 50, include_totals: a = !1, sort: o, q: s, from_date: c, to_date: l } = n, u = e.dataset || "authhero_logs", d = [`index1 = ${k(t)}`];
742
773
  if (s) {
743
- let e = de(s);
744
- d.push(...fe(e));
774
+ let { fields: e, terms: t } = pe(s);
775
+ d.push(...me(e)), d.push(...he(t));
745
776
  }
746
777
  typeof c == "number" && Number.isFinite(c) && d.push(`double2 >= ${Math.floor(c) * 1e3}`), typeof l == "number" && Number.isFinite(l) && d.push(`double2 <= ${Math.floor(l) * 1e3}`);
747
778
  let f = d.join(" AND "), p = "ORDER BY timestamp DESC";
748
- o && o.sort_by && (p = `ORDER BY ${pe(o.sort_by)} ${o.sort_order === "asc" ? "ASC" : "DESC"}`);
779
+ o && o.sort_by && (p = `ORDER BY ${ge(o.sort_by)} ${o.sort_order === "asc" ? "ASC" : "DESC"}`);
749
780
  let m = r * i, h = `LIMIT ${i} OFFSET ${m}`, g = (await O(e, `
750
781
  SELECT *
751
782
  FROM ${A(u)}
@@ -784,26 +815,26 @@ function me(e) {
784
815
  }
785
816
  //#endregion
786
817
  //#region src/analytics-engine-logs/stats.ts
787
- var N = ["s"], he = ["pwd_leak"];
788
- function P(e) {
818
+ var F = ["s"], I = ["pwd_leak"];
819
+ function L(e) {
789
820
  return `${e.slice(0, 4)}-${e.slice(4, 6)}-${e.slice(6, 8)}`;
790
821
  }
791
- function F(e) {
822
+ function R(e) {
792
823
  return e.toISOString().split("T")[0];
793
824
  }
794
- function I(e) {
825
+ function _e(e) {
795
826
  let t = e.dataset || "authhero_logs";
796
827
  return {
797
828
  async getDaily(n, r = {}) {
798
829
  let { from: i, to: a } = r, o = /* @__PURE__ */ new Date(), s = new Date(o);
799
830
  s.setDate(s.getDate() - 30);
800
- let c = i ? P(i) : F(s), l = a ? P(a) : F(o), u = (/* @__PURE__ */ new Date(`${c}T00:00:00Z`)).getTime(), d = (/* @__PURE__ */ new Date(`${l}T23:59:59.999Z`)).getTime();
831
+ let c = i ? L(i) : R(s), l = a ? L(a) : R(o), u = (/* @__PURE__ */ new Date(`${c}T00:00:00Z`)).getTime(), d = (/* @__PURE__ */ new Date(`${l}T23:59:59.999Z`)).getTime();
801
832
  return (await O(e, `
802
833
  SELECT
803
834
  toDate(toDateTime(double2 / 1000)) AS date,
804
- SUM(CASE WHEN blob3 IN (${N.map((e) => k(e)).join(", ")}) THEN 1 ELSE 0 END) AS logins,
835
+ SUM(CASE WHEN blob3 IN (${F.map((e) => k(e)).join(", ")}) THEN 1 ELSE 0 END) AS logins,
805
836
  SUM(CASE WHEN blob3 = 'ss' THEN 1 ELSE 0 END) AS signups,
806
- SUM(CASE WHEN blob3 IN (${he.map((e) => k(e)).join(", ")}) THEN 1 ELSE 0 END) AS leaked_passwords,
837
+ SUM(CASE WHEN blob3 IN (${I.map((e) => k(e)).join(", ")}) THEN 1 ELSE 0 END) AS leaked_passwords,
807
838
  MIN(double2) AS first_event,
808
839
  MAX(double2) AS last_event
809
840
  FROM "${t}"
@@ -824,7 +855,7 @@ function I(e) {
824
855
  async getActiveUsers(n) {
825
856
  let r = /* @__PURE__ */ new Date();
826
857
  r.setDate(r.getDate() - 30);
827
- let i = r.getTime(), a = N.map((e) => k(e)).join(", "), o = (await O(e, `
858
+ let i = r.getTime(), a = F.map((e) => k(e)).join(", "), o = (await O(e, `
828
859
  SELECT COUNT(DISTINCT blob7) AS count
829
860
  FROM "${t}"
830
861
  WHERE index1 = ${k(n)}
@@ -839,7 +870,7 @@ function I(e) {
839
870
  }
840
871
  //#endregion
841
872
  //#region src/analytics-engine-logs/analytics.ts
842
- var L = {
873
+ var ve = {
843
874
  "active-users": ["s", "seacft"],
844
875
  logins: [
845
876
  "s",
@@ -848,18 +879,37 @@ var L = {
848
879
  ],
849
880
  signups: ["ss", "fs"],
850
881
  "refresh-tokens": ["seacft", "fertft"],
851
- sessions: ["slo"]
852
- }, R = {
882
+ sessions: ["slo"],
883
+ logouts: ["slo", "flo"],
884
+ "password-changes": [
885
+ "scp",
886
+ "fcp",
887
+ "scpr",
888
+ "fcpr"
889
+ ],
890
+ mfa: [
891
+ "gd_auth_succeed",
892
+ "gd_auth_failed",
893
+ "gd_auth_rejected"
894
+ ],
895
+ "email-verifications": [
896
+ "sv",
897
+ "fv",
898
+ "svr",
899
+ "fvr"
900
+ ],
901
+ "codes-sent": ["cls", "cs"]
902
+ }, ye = {
853
903
  connection: "blob9",
854
904
  client_id: "blob11",
855
905
  user_type: "blob16",
856
906
  event: "blob3"
857
- }, ge = {
907
+ }, be = {
858
908
  connection: "blob9",
859
909
  client_id: "blob11",
860
910
  user_type: "blob16",
861
911
  user_id: "blob7"
862
- }, _e = {
912
+ }, xe = {
863
913
  "active-users": {
864
914
  expr: "count(DISTINCT blob7)",
865
915
  alias: "active_users",
@@ -884,9 +934,34 @@ var L = {
884
934
  expr: "count()",
885
935
  alias: "sessions",
886
936
  type: "UInt64"
937
+ },
938
+ logouts: {
939
+ expr: "count()",
940
+ alias: "logouts",
941
+ type: "UInt64"
942
+ },
943
+ "password-changes": {
944
+ expr: "count()",
945
+ alias: "password_changes",
946
+ type: "UInt64"
947
+ },
948
+ mfa: {
949
+ expr: "count()",
950
+ alias: "mfa",
951
+ type: "UInt64"
952
+ },
953
+ "email-verifications": {
954
+ expr: "count()",
955
+ alias: "email_verifications",
956
+ type: "UInt64"
957
+ },
958
+ "codes-sent": {
959
+ expr: "count()",
960
+ alias: "codes_sent",
961
+ type: "UInt64"
887
962
  }
888
963
  };
889
- function ve(e, t) {
964
+ function Se(e, t) {
890
965
  let n = `toDateTime(intDiv(double2, 1000), ${k(t)})`;
891
966
  switch (e) {
892
967
  case "hour": return `toStartOfHour(${n})`;
@@ -895,17 +970,17 @@ function ve(e, t) {
895
970
  default: return `toStartOfDay(${n})`;
896
971
  }
897
972
  }
898
- function ye(e) {
973
+ function Ce(e) {
899
974
  return e === "hour" ? "DateTime" : "Date";
900
975
  }
901
- function be(e, t, n) {
976
+ function we(e, t, n) {
902
977
  let r = new Date(e.from).getTime(), i = new Date(e.to).getTime(), a = n.map((e) => k(e)).join(", "), o = [
903
978
  `index1 = ${k(t)}`,
904
979
  `double2 >= ${r}`,
905
980
  `double2 < ${i}`,
906
981
  `blob3 IN (${a})`
907
982
  ];
908
- for (let [t, n] of Object.entries(ge)) {
983
+ for (let [t, n] of Object.entries(be)) {
909
984
  let r = e.filters[t];
910
985
  if (r && r.length > 0) {
911
986
  let e = r.map((e) => k(e)).join(", ");
@@ -914,7 +989,7 @@ function be(e, t, n) {
914
989
  }
915
990
  return o.join(" AND ");
916
991
  }
917
- function xe(e, t, n) {
992
+ function Te(e, t, n) {
918
993
  if (e.order_by) {
919
994
  let t = e.order_by.startsWith("-");
920
995
  return `${A(t ? e.order_by.slice(1) : e.order_by)} ${t ? "DESC" : "ASC"}`;
@@ -924,15 +999,15 @@ function xe(e, t, n) {
924
999
  function z(e) {
925
1000
  let t = e.dataset || "authhero_logs";
926
1001
  return { async query(n, r, i) {
927
- let a = L[r], o = _e[r], s = [], c = [];
1002
+ let a = ve[r], o = xe[r], s = [], c = [];
928
1003
  for (let e of i.group_by) if (e === "time") {
929
- let e = ve(i.interval, i.tz);
1004
+ let e = Se(i.interval, i.tz);
930
1005
  s.push(`${e} AS ${A("time")}`), c.push({
931
1006
  name: "time",
932
- type: ye(i.interval)
1007
+ type: Ce(i.interval)
933
1008
  });
934
1009
  } else {
935
- let t = R[e];
1010
+ let t = ye[e];
936
1011
  s.push(`${t} AS ${A(e)}`), c.push({
937
1012
  name: e,
938
1013
  type: "String"
@@ -942,10 +1017,10 @@ function z(e) {
942
1017
  name: o.alias,
943
1018
  type: o.type
944
1019
  });
945
- let l = [...s, `${o.expr} AS ${A(o.alias)}`], u = i.group_by.length ? `GROUP BY ${i.group_by.map((e) => A(e === "time" ? "time" : e)).join(", ")}` : "", d = xe(i, i.group_by.map((e) => e === "time" ? "time" : e), o.alias), f = `
1020
+ let l = [...s, `${o.expr} AS ${A(o.alias)}`], u = i.group_by.length ? `GROUP BY ${i.group_by.map((e) => A(e === "time" ? "time" : e)).join(", ")}` : "", d = Te(i, i.group_by.map((e) => e === "time" ? "time" : e), o.alias), f = `
946
1021
  SELECT ${l.join(", ")}
947
1022
  FROM ${A(t)}
948
- WHERE ${be(i, n, a)}
1023
+ WHERE ${we(i, n, a)}
949
1024
  ${u}
950
1025
  ORDER BY ${d}
951
1026
  LIMIT ${Math.max(0, i.limit)} OFFSET ${Math.max(0, i.offset)}
@@ -985,13 +1060,13 @@ function z(e) {
985
1060
  function B(e) {
986
1061
  return e.analyticsEngineBinding || console.warn("Analytics Engine: No binding configured. Logs will not be written to Analytics Engine."), (!e.accountId || !e.apiToken) && console.warn("Analytics Engine: accountId and apiToken are required for querying logs via SQL API."), {
987
1062
  create: ce(e),
988
- list: me(e),
1063
+ list: P(e),
989
1064
  get: ue(e)
990
1065
  };
991
1066
  }
992
1067
  //#endregion
993
1068
  //#region src/analytics-engine-action-executions/actionExecutions.ts
994
- var Se = "authhero_action_executions", Ce = 1024, we = "[truncated]";
1069
+ var Ee = "authhero_action_executions", De = 1024, Oe = "[truncated]";
995
1070
  function V(e) {
996
1071
  if (!(typeof e != "string" || e.length === 0)) try {
997
1072
  return JSON.parse(e);
@@ -999,30 +1074,30 @@ function V(e) {
999
1074
  return;
1000
1075
  }
1001
1076
  }
1002
- function Te(t) {
1077
+ function ke(t) {
1003
1078
  let n = e.safeParse(t);
1004
1079
  return n.success ? n.data : "unspecified";
1005
1080
  }
1006
- function H(e, t = Ce) {
1007
- return e.length <= t ? e : `${e.substring(0, t - 11)}${we}`;
1081
+ function H(e, t = De) {
1082
+ return e.length <= t ? e : `${e.substring(0, t - 11)}${Oe}`;
1008
1083
  }
1009
1084
  function U(e) {
1010
1085
  return e == null ? "" : JSON.stringify(e);
1011
1086
  }
1012
- function Ee(e) {
1087
+ function Ae(e) {
1013
1088
  let t = typeof e.blob6 == "string" && e.blob6.length > 0 ? e.blob6 : typeof e.double1 == "number" ? new Date(e.double1).toISOString() : "", n = typeof e.blob7 == "string" && e.blob7.length > 0 ? e.blob7 : t;
1014
1089
  return {
1015
1090
  id: typeof e.blob1 == "string" ? e.blob1 : "",
1016
1091
  tenant_id: typeof e.index1 == "string" ? e.index1 : "",
1017
1092
  trigger_id: typeof e.blob2 == "string" ? e.blob2 : "",
1018
- status: Te(e.blob3),
1093
+ status: ke(e.blob3),
1019
1094
  results: V(e.blob4) ?? [],
1020
1095
  logs: V(e.blob5),
1021
1096
  created_at: t,
1022
1097
  updated_at: n
1023
1098
  };
1024
1099
  }
1025
- function De(e) {
1100
+ function je(e) {
1026
1101
  return async (t, n) => {
1027
1102
  let r = Date.now(), i = new Date(r).toISOString(), a = {
1028
1103
  id: n.id,
@@ -1034,10 +1109,10 @@ function De(e) {
1034
1109
  created_at: i,
1035
1110
  updated_at: i
1036
1111
  };
1037
- return Oe(e, t, a, r), a;
1112
+ return Me(e, t, a, r), a;
1038
1113
  };
1039
1114
  }
1040
- function Oe(e, t, n, r) {
1115
+ function Me(e, t, n, r) {
1041
1116
  if (!e.analyticsEngineBinding) {
1042
1117
  console.error("Analytics Engine action_executions binding not configured; skipping write");
1043
1118
  return;
@@ -1060,29 +1135,29 @@ function Oe(e, t, n, r) {
1060
1135
  console.error("Failed to write action_execution to Analytics Engine:", e);
1061
1136
  }
1062
1137
  }
1063
- function ke(e) {
1138
+ function Ne(e) {
1064
1139
  return async (t, n) => {
1065
1140
  let r = await O(e, `
1066
1141
  SELECT *
1067
- FROM ${A(e.dataset || Se)}
1142
+ FROM ${A(e.dataset || Ee)}
1068
1143
  WHERE index1 = ${k(t)}
1069
1144
  AND blob1 = ${k(n)}
1070
1145
  LIMIT 1
1071
1146
  `);
1072
- return r.length === 0 || !r[0] ? null : Ee(r[0]);
1147
+ return r.length === 0 || !r[0] ? null : Ae(r[0]);
1073
1148
  };
1074
1149
  }
1075
1150
  //#endregion
1076
1151
  //#region src/analytics-engine-action-executions/index.ts
1077
1152
  function W(e) {
1078
1153
  return e.analyticsEngineBinding || console.warn("Analytics Engine: No action_executions binding configured. Executions will not be written."), (!e.accountId || !e.apiToken) && console.warn("Analytics Engine: accountId and apiToken are required to read action_executions via the SQL API."), {
1079
- create: De(e),
1080
- get: ke(e)
1154
+ create: je(e),
1155
+ get: Ne(e)
1081
1156
  };
1082
1157
  }
1083
1158
  //#endregion
1084
1159
  //#region src/geo/index.ts
1085
- function Ae() {
1160
+ function Pe() {
1086
1161
  return { async getGeoInfo(e) {
1087
1162
  try {
1088
1163
  let t = e["cf-ipcountry"], n = e["cf-ipcity"], r = e["cf-iplatitude"], i = e["cf-iplongitude"], a = e["cf-timezone"], o = e["cf-ipcontinent"];
@@ -1101,7 +1176,7 @@ function Ae() {
1101
1176
  }
1102
1177
  //#endregion
1103
1178
  //#region src/rate-limit/index.ts
1104
- var je = class {
1179
+ var Fe = class {
1105
1180
  bindings;
1106
1181
  constructor(e) {
1107
1182
  this.bindings = e;
@@ -1118,7 +1193,7 @@ var je = class {
1118
1193
  }
1119
1194
  };
1120
1195
  function G(e) {
1121
- if (e && Object.keys(e).some((t) => e[t])) return new je(e);
1196
+ if (e && Object.keys(e).some((t) => e[t])) return new Fe(e);
1122
1197
  }
1123
1198
  //#endregion
1124
1199
  //#region src/code-executor/worker-template.ts
@@ -1316,12 +1391,12 @@ var q = class {
1316
1391
  throw Error(`Failed to remove hook worker ${t}: ${r.status} ${e}`);
1317
1392
  }
1318
1393
  }
1319
- }, Me = q, Ne = {
1394
+ }, Ie = q, Le = {
1320
1395
  "post-user-login": "onExecutePostLogin",
1321
1396
  "credentials-exchange": "onExecuteCredentialsExchange",
1322
1397
  "pre-user-registration": "onExecutePreUserRegistration",
1323
1398
  "post-user-registration": "onExecutePostUserRegistration"
1324
- }, Pe = {
1399
+ }, Re = {
1325
1400
  "post-user-login": {
1326
1401
  accessToken: ["setCustomClaim"],
1327
1402
  idToken: ["setCustomClaim"],
@@ -1340,15 +1415,15 @@ var q = class {
1340
1415
  },
1341
1416
  "post-user-registration": {}
1342
1417
  };
1343
- async function Fe(e) {
1418
+ async function ze(e) {
1344
1419
  let t = new TextEncoder().encode(e), n = await crypto.subtle.digest("SHA-256", t), r = new Uint8Array(n), i = "";
1345
1420
  for (let e of r) i += e.toString(16).padStart(2, "0");
1346
1421
  return i;
1347
1422
  }
1348
- function Ie(e) {
1423
+ function Be(e) {
1349
1424
  return `
1350
- const TRIGGER_FN_NAMES = ${JSON.stringify(Ne)};
1351
- const API_SHAPES = ${JSON.stringify(Pe)};
1425
+ const TRIGGER_FN_NAMES = ${JSON.stringify(Le)};
1426
+ const API_SHAPES = ${JSON.stringify(Re)};
1352
1427
  const MAX_LOG_ENTRIES = 50;
1353
1428
  const MAX_LOG_LENGTH = 500;
1354
1429
 
@@ -1448,7 +1523,7 @@ export default {
1448
1523
  };
1449
1524
  `;
1450
1525
  }
1451
- var Le = class {
1526
+ var Ve = class {
1452
1527
  loader;
1453
1528
  compatibilityDate;
1454
1529
  constructor(e) {
@@ -1457,11 +1532,11 @@ var Le = class {
1457
1532
  async execute(e) {
1458
1533
  let t = Date.now();
1459
1534
  try {
1460
- let t = Ie(e.code), n = {
1535
+ let t = Be(e.code), n = {
1461
1536
  compatibilityDate: this.compatibilityDate,
1462
1537
  mainModule: "hook.js",
1463
1538
  modules: { "hook.js": t }
1464
- }, r = e.hookCodeId ? `${e.hookCodeId}-${await Fe(e.code)}` : null;
1539
+ }, r = e.hookCodeId ? `${e.hookCodeId}-${await ze(e.code)}` : null;
1465
1540
  return await (await (r ? this.loader.get(r, async () => n) : this.loader.load(n)).getEntrypoint().fetch(new Request("https://hook/execute", {
1466
1541
  method: "POST",
1467
1542
  headers: { "Content-Type": "application/json" },
@@ -1485,10 +1560,10 @@ var Le = class {
1485
1560
  errors;
1486
1561
  body;
1487
1562
  constructor(e, t, n, r = []) {
1488
- super(`Cloudflare API ${e} ${t}: ${Re(n, 256)}`), this.name = "CloudflareApiError", this.status = e, this.endpoint = t, this.body = n, this.errors = r;
1563
+ super(`Cloudflare API ${e} ${t}: ${He(n, 256)}`), this.name = "CloudflareApiError", this.status = e, this.endpoint = t, this.body = n, this.errors = r;
1489
1564
  }
1490
1565
  };
1491
- function Re(e, t) {
1566
+ function He(e, t) {
1492
1567
  return e.length <= t ? e : `${e.slice(0, t)}…`;
1493
1568
  }
1494
1569
  var Y = class {
@@ -1566,11 +1641,11 @@ var Y = class {
1566
1641
  }
1567
1642
  if (!(c === "" || s.status === 204)) return JSON.parse(c);
1568
1643
  }
1569
- }, ze = "{tenant_id}", Be = "tenant-{tenant_id}", Ve = "index.js", He = "2026-05-01", X = 64;
1570
- function Z(e, t) {
1644
+ }, Ue = "{tenant_id}", We = "tenant-{tenant_id}", X = "index.js", Ge = "2026-05-01", Z = 64;
1645
+ function Q(e, t) {
1571
1646
  return e.replace(/\{tenant_id\}/g, t);
1572
1647
  }
1573
- function Q(e) {
1648
+ function Ke(e) {
1574
1649
  if (!(e instanceof J)) return !1;
1575
1650
  let t = e.body.toLowerCase();
1576
1651
  return e.status === 409 || t.includes("already exists") || t.includes("name is already taken") || t.includes("already in use");
@@ -1578,13 +1653,13 @@ function Q(e) {
1578
1653
  function $(e) {
1579
1654
  return e instanceof J ? e.status === 404 : !1;
1580
1655
  }
1581
- function Ue(e) {
1656
+ function qe(e) {
1582
1657
  let t = new Y({
1583
1658
  accountId: e.accountId,
1584
1659
  apiToken: e.apiToken,
1585
1660
  fetch: e.fetch,
1586
1661
  timeoutMs: e.timeoutMs
1587
- }), n = e.scriptNameTemplate ?? ze, r = e.d1NameTemplate ?? Be, i = e.scriptMetadata?.main_module ?? Ve, a = e.scriptMetadata?.compatibility_date ?? He, o = e.scriptMetadata?.compatibility_flags ?? ["nodejs_compat"], s = e.dispatchNamespace, c = e.logger;
1662
+ }), n = e.scriptNameTemplate ?? Ue, r = e.d1NameTemplate ?? We, i = e.scriptMetadata?.main_module ?? X, a = e.scriptMetadata?.compatibility_date ?? Ge, o = e.scriptMetadata?.compatibility_flags ?? ["nodejs_compat"], s = e.dispatchNamespace, c = e.logger;
1588
1663
  async function l(e) {
1589
1664
  let n = (await t.listD1Databases(e)).find((t) => t.name === e);
1590
1665
  if (n) return {
@@ -1597,7 +1672,7 @@ function Ue(e) {
1597
1672
  created: !0
1598
1673
  };
1599
1674
  } catch (n) {
1600
- if (!Q(n)) throw n;
1675
+ if (!Ke(n)) throw n;
1601
1676
  let r = (await t.listD1Databases(e)).find((t) => t.name === e);
1602
1677
  if (r) return {
1603
1678
  id: r.uuid,
@@ -1672,8 +1747,8 @@ function Ue(e) {
1672
1747
  }
1673
1748
  return {
1674
1749
  async onProvision(t) {
1675
- let i = Z(n, t), a = Z(r, t), o = e.migrations[e.migrations.length - 1]?.name;
1676
- if (o !== void 0 && o.length > X) throw Error(`Migration name "${o}" exceeds the ${X}-character database_version limit.`);
1750
+ let i = Q(n, t), a = Q(r, t), o = e.migrations[e.migrations.length - 1]?.name;
1751
+ if (o !== void 0 && o.length > Z) throw Error(`Migration name "${o}" exceeds the ${Z}-character database_version limit.`);
1677
1752
  let { id: s, created: u } = await l(a), d = u ? !1 : await f(s);
1678
1753
  if (u || d) await p(s), await _(s);
1679
1754
  else {
@@ -1690,7 +1765,7 @@ function Ue(e) {
1690
1765
  };
1691
1766
  },
1692
1767
  async onDeprovision(e) {
1693
- let i = Z(n, e), a = Z(r, e), o = [];
1768
+ let i = Q(n, e), a = Q(r, e), o = [];
1694
1769
  try {
1695
1770
  await t.deleteNamespacedScript(s, i);
1696
1771
  } catch (e) {
@@ -1715,17 +1790,17 @@ function Ue(e) {
1715
1790
  }
1716
1791
  //#endregion
1717
1792
  //#region src/wfp-provisioner/tenant-hook.ts
1718
- function We(e) {
1793
+ function Je(e) {
1719
1794
  return e.deployment_type === "wfp";
1720
1795
  }
1721
- function Ge(e) {
1796
+ function Ye(e) {
1722
1797
  if (typeof e != "object" || !e) return [];
1723
1798
  let t = [];
1724
1799
  for (let n of Object.values(e)) if (typeof n == "object" && n && "errors" in n && Array.isArray(n.errors)) for (let e of n.errors) typeof e == "string" && t.push(e);
1725
1800
  return t;
1726
1801
  }
1727
- function Ke(e) {
1728
- let { provisioner: t, tenants: n, syncDefaults: r } = e, i = e.shouldProvision ?? We, a = e.logger;
1802
+ function Xe(e) {
1803
+ let { provisioner: t, tenants: n, syncDefaults: r } = e, i = e.shouldProvision ?? Je, a = e.logger;
1729
1804
  async function o(e, t) {
1730
1805
  let r = t instanceof Error ? t.message : String(t);
1731
1806
  try {
@@ -1754,7 +1829,7 @@ function Ke(e) {
1754
1829
  };
1755
1830
  try {
1756
1831
  if (r) {
1757
- let t = Ge(await r(e));
1832
+ let t = Ye(await r(e));
1758
1833
  if (t.length > 0) throw Error(`sync-defaults seed reported ${t.length} error(s): ${t.join("; ")}`);
1759
1834
  }
1760
1835
  await n.update(e, {
@@ -1806,23 +1881,23 @@ function Ke(e) {
1806
1881
  }
1807
1882
  //#endregion
1808
1883
  //#region src/wfp-provisioner/wfp-forward.ts
1809
- var qe = "DISPATCHER", Je = "tenant-{tenant_id}-auth";
1810
- function Ye(e) {
1884
+ var Ze = "DISPATCHER", Qe = "tenant-{tenant_id}-auth";
1885
+ function $e(e) {
1811
1886
  return typeof e == "object" && !!e && "get" in e && typeof Reflect.get(e, "get") == "function";
1812
1887
  }
1813
- function Xe(e, t) {
1888
+ function et(e, t) {
1814
1889
  return e.replace(/\{tenant_id\}/g, t);
1815
1890
  }
1816
- function Ze(e) {
1817
- let { tenants: t, controlPlaneTenantId: n, dispatcherBinding: r = qe, scriptNameTemplate: i = Je, resolveTenantId: a = (e) => e.req.header("tenant-id") } = e;
1891
+ function tt(e) {
1892
+ let { tenants: t, controlPlaneTenantId: n, dispatcherBinding: r = Ze, scriptNameTemplate: i = Qe, resolveTenantId: a = (e) => e.req.header("tenant-id") } = e;
1818
1893
  return async (e, o) => {
1819
1894
  let s = await a(e);
1820
1895
  if (!s || s === n) return o();
1821
1896
  let c = await t.get(s);
1822
1897
  if (!c || c.deployment_type !== "wfp" || c.provisioning_state && c.provisioning_state !== "ready") return o();
1823
1898
  let l = Reflect.get(e.env ?? {}, r);
1824
- if (!Ye(l)) return o();
1825
- let u = Xe(i, s), d;
1899
+ if (!$e(l)) return o();
1900
+ let u = et(i, s), d;
1826
1901
  try {
1827
1902
  d = await l.get(u).fetch(e.req.raw);
1828
1903
  } catch (t) {
@@ -1845,7 +1920,7 @@ function Ze(e) {
1845
1920
  }
1846
1921
  //#endregion
1847
1922
  //#region src/index.ts
1848
- function Qe(e) {
1923
+ function nt(e) {
1849
1924
  let t = {
1850
1925
  customDomains: y(e),
1851
1926
  cache: te({
@@ -1853,11 +1928,11 @@ function Qe(e) {
1853
1928
  ...e.defaultTtlSeconds !== void 0 && { defaultTtlSeconds: e.defaultTtlSeconds },
1854
1929
  ...e.keyPrefix && { keyPrefix: e.keyPrefix }
1855
1930
  }),
1856
- geo: Ae()
1931
+ geo: Pe()
1857
1932
  };
1858
1933
  e.r2SqlLogs ? t.logs = D(e.r2SqlLogs) : e.analyticsEngineLogs && (t.logs = B(e.analyticsEngineLogs)), e.analyticsEngineLogs && (t.analytics = z(e.analyticsEngineLogs)), e.analyticsEngineActionExecutions && (t.actionExecutions = W(e.analyticsEngineActionExecutions));
1859
1934
  let n = G(e.rateLimitBindings);
1860
1935
  return n && (t.rateLimit = n), t;
1861
1936
  }
1862
1937
  //#endregion
1863
- export { Y as CloudflareApiClient, J as CloudflareApiError, Me as CloudflareCodeExecutor, q as DispatchNamespaceCodeExecutor, Le as WorkerLoaderCodeExecutor, W as createAnalyticsEngineActionExecutionsAdapter, z as createAnalyticsEngineAnalyticsAdapter, B as createAnalyticsEngineLogsAdapter, I as createAnalyticsEngineStatsAdapter, G as createCloudflareRateLimitAdapter, Ue as createCloudflareWfpD1Provisioner, D as createR2SQLLogsAdapter, se as createR2SQLStatsAdapter, Ze as createWfpForwardMiddleware, Ke as createWfpTenantProvisioningHook, Qe as default, K as generateWorkerScript };
1938
+ export { Y as CloudflareApiClient, J as CloudflareApiError, Ie as CloudflareCodeExecutor, q as DispatchNamespaceCodeExecutor, Ve as WorkerLoaderCodeExecutor, W as createAnalyticsEngineActionExecutionsAdapter, z as createAnalyticsEngineAnalyticsAdapter, B as createAnalyticsEngineLogsAdapter, _e as createAnalyticsEngineStatsAdapter, G as createCloudflareRateLimitAdapter, qe as createCloudflareWfpD1Provisioner, D as createR2SQLLogsAdapter, se as createR2SQLStatsAdapter, tt as createWfpForwardMiddleware, Xe as createWfpTenantProvisioningHook, nt as default, K as generateWorkerScript };