@authhero/cloudflare-adapter 2.37.5 → 2.38.0

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.
@@ -1,84 +1,85 @@
1
- import { actionExecutionStatusSchema as e, verificationMethodsSchema as t } from "@authhero/adapter-interfaces";
2
- import { z as n } from "@hono/zod-openapi";
3
- import { HTTPException as r } from "hono/http-exception";
4
- import i from "wretch";
5
- import { dedupe as a, retry as o } from "wretch/middlewares";
1
+ import { a as e, i as t, n, t as r } from "./sync-defaults-errors-BlLZh6Gt.mjs";
2
+ import { actionExecutionStatusSchema as i, verificationMethodsSchema as a } from "@authhero/adapter-interfaces";
3
+ import { z as o } from "@hono/zod-openapi";
4
+ import { HTTPException as s } from "hono/http-exception";
5
+ import c from "wretch";
6
+ import { dedupe as l, retry as u } from "wretch/middlewares";
6
7
  //#region src/types/CustomDomain.ts
7
- var s = n.object({
8
- code: n.number(),
9
- message: n.string()
10
- }), c = n.object({ message: n.string() }), l = n.object({
11
- emails: n.array(n.string()).optional(),
12
- http_body: n.string().optional(),
13
- http_url: n.string().optional(),
14
- txt_name: n.string().optional(),
15
- txt_value: n.string().optional()
16
- }), u = n.object({
17
- ciphers: n.array(n.string()).optional(),
18
- early_hints: n.string().optional(),
19
- http2: n.string().optional(),
20
- min_tls_version: n.string().optional(),
21
- tls_1_3: n.string().optional()
22
- }), d = n.object({
23
- id: n.string(),
24
- bundle_method: n.string().optional(),
25
- certificate_authority: n.string(),
26
- custom_certificate: n.string().optional(),
27
- custom_csr_id: n.string().optional(),
28
- custom_key: n.string().optional(),
29
- expires_on: n.string().optional(),
30
- hosts: n.array(n.string()).optional(),
31
- issuer: n.string().optional(),
32
- method: n.string(),
33
- serial_number: n.string().optional(),
34
- settings: u.optional(),
35
- signature: n.string().optional(),
36
- type: n.string(),
37
- uploaded_on: n.string().optional(),
38
- validation_errors: n.array(c).optional(),
39
- validation_records: n.array(l).optional(),
40
- wildcard: n.boolean()
41
- }), f = n.object({
42
- name: n.string(),
43
- type: n.string(),
44
- value: n.string()
45
- }), p = n.object({
46
- http_body: n.string().optional(),
47
- http_url: n.string().optional()
48
- }), m = n.object({
49
- id: n.string(),
50
- ssl: d,
51
- hostname: n.string(),
52
- custom_metadata: n.record(n.string(), n.string()).optional(),
53
- custom_origin_server: n.string().optional(),
54
- custom_origin_sni: n.string().optional(),
55
- ownership_verification: f.optional(),
56
- ownership_verification_http: p.optional(),
57
- status: n.string(),
58
- verification_errors: n.array(n.string()).optional(),
59
- created_at: n.string()
60
- }), h = n.object({
61
- errors: n.array(s),
62
- messages: n.array(s),
63
- success: n.boolean(),
64
- result: m
8
+ var d = o.object({
9
+ code: o.number(),
10
+ message: o.string()
11
+ }), f = o.object({ message: o.string() }), p = o.object({
12
+ emails: o.array(o.string()).optional(),
13
+ http_body: o.string().optional(),
14
+ http_url: o.string().optional(),
15
+ txt_name: o.string().optional(),
16
+ txt_value: o.string().optional()
17
+ }), m = o.object({
18
+ ciphers: o.array(o.string()).optional(),
19
+ early_hints: o.string().optional(),
20
+ http2: o.string().optional(),
21
+ min_tls_version: o.string().optional(),
22
+ tls_1_3: o.string().optional()
23
+ }), h = o.object({
24
+ id: o.string(),
25
+ bundle_method: o.string().optional(),
26
+ certificate_authority: o.string(),
27
+ custom_certificate: o.string().optional(),
28
+ custom_csr_id: o.string().optional(),
29
+ custom_key: o.string().optional(),
30
+ expires_on: o.string().optional(),
31
+ hosts: o.array(o.string()).optional(),
32
+ issuer: o.string().optional(),
33
+ method: o.string(),
34
+ serial_number: o.string().optional(),
35
+ settings: m.optional(),
36
+ signature: o.string().optional(),
37
+ type: o.string(),
38
+ uploaded_on: o.string().optional(),
39
+ validation_errors: o.array(f).optional(),
40
+ validation_records: o.array(p).optional(),
41
+ wildcard: o.boolean()
42
+ }), g = o.object({
43
+ name: o.string(),
44
+ type: o.string(),
45
+ value: o.string()
46
+ }), _ = o.object({
47
+ http_body: o.string().optional(),
48
+ http_url: o.string().optional()
49
+ }), v = o.object({
50
+ id: o.string(),
51
+ ssl: h,
52
+ hostname: o.string(),
53
+ custom_metadata: o.record(o.string(), o.string()).optional(),
54
+ custom_origin_server: o.string().optional(),
55
+ custom_origin_sni: o.string().optional(),
56
+ ownership_verification: g.optional(),
57
+ ownership_verification_http: _.optional(),
58
+ status: o.string(),
59
+ verification_errors: o.array(o.string()).optional(),
60
+ created_at: o.string()
61
+ }), y = o.object({
62
+ errors: o.array(d),
63
+ messages: o.array(d),
64
+ success: o.boolean(),
65
+ result: v
65
66
  });
66
- n.object({
67
- errors: n.array(s),
68
- messages: n.array(s),
69
- success: n.boolean(),
70
- result: n.array(m)
67
+ o.object({
68
+ errors: o.array(d),
69
+ messages: o.array(d),
70
+ success: o.boolean(),
71
+ result: o.array(v)
71
72
  });
72
73
  //#endregion
73
74
  //#region src/customDomains/index.ts
74
- function g(e) {
75
- return i(`https://api.cloudflare.com/client/v4/zones/${e.zoneId}`).headers({
75
+ function b(e) {
76
+ return c(`https://api.cloudflare.com/client/v4/zones/${e.zoneId}`).headers({
76
77
  "X-Auth-Email": e.authEmail,
77
78
  "X-Auth-Key": e.authKey,
78
79
  "Content-Type": "application/json"
79
- }).middlewares([o(), a()]);
80
+ }).middlewares([u(), l()]);
80
81
  }
81
- function _(e) {
82
+ function x(e) {
82
83
  let t = {}, n = {};
83
84
  if (!e) return {
84
85
  sslOverrides: t,
@@ -90,27 +91,27 @@ function _(e) {
90
91
  rest: n
91
92
  };
92
93
  }
93
- function v(e) {
94
- let r = [];
95
- if (e.ssl.validation_records) for (let t of e.ssl.validation_records) t.txt_name && t.txt_value && r.push({
94
+ function S(e) {
95
+ let t = [];
96
+ if (e.ssl.validation_records) for (let n of e.ssl.validation_records) n.txt_name && n.txt_value && t.push({
96
97
  name: "txt",
97
- record: t.txt_value,
98
- domain: t.txt_name
98
+ record: n.txt_value,
99
+ domain: n.txt_name
99
100
  });
100
- if (e.ownership_verification && r.push({
101
+ if (e.ownership_verification && t.push({
101
102
  name: "txt",
102
103
  record: e.ownership_verification.value,
103
104
  domain: e.ownership_verification.name
104
- }), e.ownership_verification_http?.http_body && e.ownership_verification_http?.http_url && r.push({
105
+ }), e.ownership_verification_http?.http_body && e.ownership_verification_http?.http_url && t.push({
105
106
  name: "http",
106
107
  http_body: e.ownership_verification_http.http_body,
107
108
  http_url: e.ownership_verification_http.http_url
108
- }), e.ssl.validation_records) for (let t of e.ssl.validation_records) t.http_body && t.http_url && r.push({
109
+ }), e.ssl.validation_records) for (let n of e.ssl.validation_records) n.http_body && n.http_url && t.push({
109
110
  name: "http",
110
- http_body: t.http_body,
111
- http_url: t.http_url
111
+ http_body: n.http_body,
112
+ http_url: n.http_url
112
113
  });
113
- let i = {
114
+ let n = {
114
115
  ...e.domain_metadata || {},
115
116
  "ssl.method": e.ssl.method,
116
117
  "ssl.type": e.ssl.type,
@@ -122,14 +123,14 @@ function v(e) {
122
123
  primary: e.primary,
123
124
  status: e.status === "active" ? "ready" : "pending",
124
125
  type: e.type ?? "auth0_managed_certs",
125
- verification: { methods: n.array(t).parse(r) },
126
- domain_metadata: i
126
+ verification: { methods: o.array(a).parse(t) },
127
+ domain_metadata: n
127
128
  };
128
129
  }
129
- function y(e) {
130
+ function ee(e) {
130
131
  return {
131
132
  create: async (t, n) => {
132
- let { sslOverrides: r, rest: i } = _(n.domain_metadata), { result: a, errors: o, success: s } = h.parse(await g(e).post({
133
+ let { sslOverrides: r, rest: i } = x(n.domain_metadata), { result: a, errors: o, success: s } = y.parse(await b(e).post({
133
134
  hostname: n.domain,
134
135
  ssl: {
135
136
  method: "txt",
@@ -139,7 +140,7 @@ function y(e) {
139
140
  custom_metadata: e.enterprise ? { tenant_id: t } : void 0
140
141
  }, "/custom_hostnames").json());
141
142
  if (!s) throw Error(JSON.stringify(o));
142
- let c = v({
143
+ let c = S({
143
144
  ...a,
144
145
  primary: !1,
145
146
  type: n.type,
@@ -157,31 +158,31 @@ function y(e) {
157
158
  }), c;
158
159
  },
159
160
  get: async (t, n) => {
160
- let i = await e.customDomainAdapter.get(t, n);
161
- if (!i) throw new r(404);
162
- let a;
161
+ let r = await e.customDomainAdapter.get(t, n);
162
+ if (!r) throw new s(404);
163
+ let i;
163
164
  try {
164
- a = await g(e).get(`/custom_hostnames/${encodeURIComponent(n)}`).json();
165
+ i = await b(e).get(`/custom_hostnames/${encodeURIComponent(n)}`).json();
165
166
  } catch (e) {
166
- return console.warn(`[custom-domains] CF fetch failed for ${n} (tenant=${t}); returning stale DB row:`, e instanceof Error ? e.message : e), i;
167
+ return console.warn(`[custom-domains] CF fetch failed for ${n} (tenant=${t}); returning stale DB row:`, e instanceof Error ? e.message : e), r;
167
168
  }
168
- let o = h.safeParse(a);
169
- if (!o.success || !o.data.success) return console.warn(`[custom-domains] CF response unparseable for ${n} (tenant=${t}); returning stale DB row.`, o.success ? { cfErrors: o.data.errors } : {
170
- zodIssues: o.error.issues,
171
- body: a
172
- }), i;
173
- let { result: s } = o.data;
174
- if (e.enterprise && s.custom_metadata?.tenant_id !== t) throw new r(404);
169
+ let a = y.safeParse(i);
170
+ if (!a.success || !a.data.success) return console.warn(`[custom-domains] CF response unparseable for ${n} (tenant=${t}); returning stale DB row.`, a.success ? { cfErrors: a.data.errors } : {
171
+ zodIssues: a.error.issues,
172
+ body: i
173
+ }), r;
174
+ let { result: o } = a.data;
175
+ if (e.enterprise && o.custom_metadata?.tenant_id !== t) throw new s(404);
175
176
  let c;
176
177
  try {
177
- c = v({
178
- ...i,
179
- ...s
178
+ c = S({
179
+ ...r,
180
+ ...o
180
181
  });
181
182
  } catch (e) {
182
- return console.warn(`[custom-domains] mapCustomDomainResponse failed for ${n} (tenant=${t}); returning stale DB row.`, e instanceof Error ? e.message : e), i;
183
+ return console.warn(`[custom-domains] mapCustomDomainResponse failed for ${n} (tenant=${t}); returning stale DB row.`, e instanceof Error ? e.message : e), r;
183
184
  }
184
- if (c.status !== i.status || JSON.stringify(c.verification) !== JSON.stringify(i.verification)) try {
185
+ if (c.status !== r.status || JSON.stringify(c.verification) !== JSON.stringify(r.verification)) try {
185
186
  await e.customDomainAdapter.update(t, n, {
186
187
  status: c.status,
187
188
  verification: c.verification
@@ -195,49 +196,49 @@ function y(e) {
195
196
  list: async (t) => e.customDomainAdapter.list(t),
196
197
  remove: async (t, n) => {
197
198
  if (e.enterprise) {
198
- let { result: i, success: a } = h.parse(await g(e).get(`/custom_hostnames/${encodeURIComponent(n)}`).json());
199
- if (!a || i.custom_metadata?.tenant_id !== t) throw new r(404);
199
+ let { result: r, success: i } = y.parse(await b(e).get(`/custom_hostnames/${encodeURIComponent(n)}`).json());
200
+ if (!i || r.custom_metadata?.tenant_id !== t) throw new s(404);
200
201
  }
201
- let i = await g(e).delete(`/custom_hostnames/${encodeURIComponent(n)}`).res();
202
- return i.ok && await e.customDomainAdapter.remove(t, n), i.ok;
202
+ let r = await b(e).delete(`/custom_hostnames/${encodeURIComponent(n)}`).res();
203
+ return r.ok && await e.customDomainAdapter.remove(t, n), r.ok;
203
204
  },
204
- update: async (t, n, i) => {
205
- let { sslOverrides: a } = _(i.domain_metadata), o = {};
206
- if (Object.keys(a).length > 0) {
205
+ update: async (t, n, r) => {
206
+ let { sslOverrides: i } = x(r.domain_metadata), a = {};
207
+ if (Object.keys(i).length > 0) {
207
208
  let t;
208
209
  try {
209
- t = await g(e).get(`/custom_hostnames/${encodeURIComponent(n)}`).json();
210
+ t = await b(e).get(`/custom_hostnames/${encodeURIComponent(n)}`).json();
210
211
  } catch (e) {
211
- throw new r(503, { message: `Failed to fetch current custom hostname state: ${e instanceof Error ? e.message : String(e)}` });
212
+ throw new s(503, { message: `Failed to fetch current custom hostname state: ${e instanceof Error ? e.message : String(e)}` });
212
213
  }
213
- let i = h.safeParse(t);
214
- if (!i.success || !i.data.success) throw new r(503, { message: `Failed to parse current custom hostname state: ${JSON.stringify(i.success ? i.data.errors : i.error.issues)}` });
215
- o.ssl = {
216
- method: i.data.result.ssl.method,
217
- type: i.data.result.ssl.type,
218
- certificate_authority: i.data.result.ssl.certificate_authority,
219
- ...a
214
+ let r = y.safeParse(t);
215
+ if (!r.success || !r.data.success) throw new s(503, { message: `Failed to parse current custom hostname state: ${JSON.stringify(r.success ? r.data.errors : r.error.issues)}` });
216
+ a.ssl = {
217
+ method: r.data.result.ssl.method,
218
+ type: r.data.result.ssl.type,
219
+ certificate_authority: r.data.result.ssl.certificate_authority,
220
+ ...i
220
221
  };
221
222
  }
222
- if (Object.keys(o).length > 0) {
223
- let t = await g(e).patch(o, `/custom_hostnames/${encodeURIComponent(n)}`).res().catch((e) => {
224
- throw new r(503, { message: `Failed to update custom hostname: ${e instanceof Error ? e.message : String(e)}` });
223
+ if (Object.keys(a).length > 0) {
224
+ let t = await b(e).patch(a, `/custom_hostnames/${encodeURIComponent(n)}`).res().catch((e) => {
225
+ throw new s(503, { message: `Failed to update custom hostname: ${e instanceof Error ? e.message : String(e)}` });
225
226
  });
226
- if (!t.ok) throw new r(503, { message: await t.text() });
227
+ if (!t.ok) throw new s(503, { message: await t.text() });
227
228
  }
228
- return e.customDomainAdapter.update(t, n, i);
229
+ return e.customDomainAdapter.update(t, n, r);
229
230
  },
230
- uploadCertificate: async (t, n, i) => {
231
- let a = await e.customDomainAdapter.get(t, n);
232
- if (!a) throw new r(404);
233
- let o = await g(e).patch({ ssl: {
234
- custom_certificate: i.certificate,
235
- custom_key: i.private_key
236
- } }, `/custom_hostnames/${encodeURIComponent(n)}`).json(), { result: s, errors: c, success: l } = h.parse(o);
237
- if (!l) throw new r(503, { message: JSON.stringify(c) });
238
- let u = v({
239
- ...a,
240
- ...s
231
+ uploadCertificate: async (t, n, r) => {
232
+ let i = await e.customDomainAdapter.get(t, n);
233
+ if (!i) throw new s(404);
234
+ let a = await b(e).patch({ ssl: {
235
+ custom_certificate: r.certificate,
236
+ custom_key: r.private_key
237
+ } }, `/custom_hostnames/${encodeURIComponent(n)}`).json(), { result: o, errors: c, success: l } = y.parse(a);
238
+ if (!l) throw new s(503, { message: JSON.stringify(c) });
239
+ let u = S({
240
+ ...i,
241
+ ...o
241
242
  });
242
243
  return await e.customDomainAdapter.update(t, n, {
243
244
  status: u.status,
@@ -248,7 +249,7 @@ function y(e) {
248
249
  }
249
250
  //#endregion
250
251
  //#region src/cache/index.ts
251
- var ee = class {
252
+ var te = class {
252
253
  config;
253
254
  cache = null;
254
255
  constructor(e) {
@@ -322,8 +323,8 @@ var ee = class {
322
323
  console.warn("CloudflareCache.clear() is not implemented - Cloudflare Cache API does not support clearing all entries");
323
324
  }
324
325
  };
325
- function te(e = {}) {
326
- return new ee({
326
+ function ne(e = {}) {
327
+ return new te({
327
328
  defaultTtlSeconds: 300,
328
329
  keyPrefix: "authhero",
329
330
  getTimeoutMs: 200,
@@ -332,14 +333,14 @@ function te(e = {}) {
332
333
  }
333
334
  //#endregion
334
335
  //#region ../../node_modules/.pnpm/nanoid@5.1.16/node_modules/nanoid/url-alphabet/index.js
335
- var ne = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", b = (e = 21) => {
336
+ var re = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", C = (e = 21) => {
336
337
  let t = "", n = crypto.getRandomValues(new Uint8Array(e |= 0));
337
- for (; e--;) t += ne[n[e] & 63];
338
+ for (; e--;) t += re[n[e] & 63];
338
339
  return t;
339
340
  };
340
341
  //#endregion
341
342
  //#region src/r2-sql-logs/query.ts
342
- async function x(e, t) {
343
+ async function w(e, t) {
343
344
  let n = e.timeout || 3e4, r = new AbortController(), i = setTimeout(() => r.abort(), n);
344
345
  try {
345
346
  let n = `https://api.sql.cloudflarestorage.com/api/v1/accounts/${e.accountId}/r2-sql/query/${e.warehouseName}`, i = await fetch(n, {
@@ -359,15 +360,15 @@ async function x(e, t) {
359
360
  clearTimeout(i);
360
361
  }
361
362
  }
362
- function S(e) {
363
+ function T(e) {
363
364
  return `'${e.replace(/'/g, "''")}'`;
364
365
  }
365
- function C(e) {
366
+ function E(e) {
366
367
  return `"${e.replace(/"/g, "\"\"")}"`;
367
368
  }
368
369
  //#endregion
369
370
  //#region src/r2-sql-logs/logs.ts
370
- function w(e) {
371
+ function D(e) {
371
372
  let t = (e) => {
372
373
  if (!e) return "";
373
374
  try {
@@ -407,16 +408,16 @@ function w(e) {
407
408
  } : void 0
408
409
  };
409
410
  }
410
- function re(e) {
411
+ function ie(e) {
411
412
  return async (t, n) => {
412
- let r = n.log_id || b(), i = {
413
+ let r = n.log_id || C(), i = {
413
414
  ...n,
414
415
  log_id: r
415
416
  };
416
- return await ie(e, t, i), i;
417
+ return await ae(e, t, i), i;
417
418
  };
418
419
  }
419
- async function ie(e, t, n) {
420
+ async function ae(e, t, n) {
420
421
  let r = (e) => e ? JSON.stringify(e) : void 0, i = {
421
422
  id: n.log_id,
422
423
  tenant_id: t,
@@ -467,22 +468,22 @@ async function ie(e, t, n) {
467
468
  throw console.error("Failed to send log to Pipeline:", e), e;
468
469
  }
469
470
  }
470
- function ae(e) {
471
+ function oe(e) {
471
472
  return async (t, n) => {
472
- let r = e.namespace || "default", i = e.tableName || "logs", a = await x(e, `
473
- SELECT * FROM ${C(r)}.${C(i)}
474
- WHERE tenant_id = ${S(t)}
475
- AND id = ${S(n)}
473
+ let r = e.namespace || "default", i = e.tableName || "logs", a = await w(e, `
474
+ SELECT * FROM ${E(r)}.${E(i)}
475
+ WHERE tenant_id = ${T(t)}
476
+ AND id = ${T(n)}
476
477
  LIMIT 1
477
478
  `);
478
479
  if (a.length === 0) return null;
479
480
  let o = a[0];
480
- return o ? w(o) : null;
481
+ return o ? D(o) : null;
481
482
  };
482
483
  }
483
484
  //#endregion
484
485
  //#region src/r2-sql-logs/list.ts
485
- function oe(e) {
486
+ function O(e) {
486
487
  let t = {}, n = /(\w+):(?:"([^"]*)"|(\S+))/g, r;
487
488
  for (; (r = n.exec(e)) !== null;) {
488
489
  let e = r[1], n = r[2] === void 0 ? r[3] : r[2];
@@ -490,40 +491,40 @@ function oe(e) {
490
491
  }
491
492
  return t;
492
493
  }
493
- function T(e) {
494
+ function se(e) {
494
495
  let t = [];
495
496
  for (let [n, r] of Object.entries(e)) {
496
497
  let e = n.replace(/[^a-zA-Z0-9_]/g, "");
497
- e && r && t.push(`${C(e)} = ${S(r)}`);
498
+ e && r && t.push(`${E(e)} = ${T(r)}`);
498
499
  }
499
500
  return t;
500
501
  }
501
- function E(e) {
502
+ function ce(e) {
502
503
  return async (t, n = {}) => {
503
- let { page: r = 0, per_page: i = 50, include_totals: a = !1, sort: o, q: s } = n, c = e.namespace || "default", l = e.tableName || "logs", u = [`tenant_id = ${S(t)}`];
504
+ let { page: r = 0, per_page: i = 50, include_totals: a = !1, sort: o, q: s } = n, c = e.namespace || "default", l = e.tableName || "logs", u = [`tenant_id = ${T(t)}`];
504
505
  if (s) {
505
- let e = oe(s);
506
- u.push(...T(e));
506
+ let e = O(s);
507
+ u.push(...se(e));
507
508
  }
508
509
  let d = u.join(" AND "), f = "ORDER BY date DESC";
509
510
  if (o && o.sort_by) {
510
511
  let e = o.sort_by.replace(/[^a-zA-Z0-9_]/g, ""), t = o.sort_order === "asc" ? "ASC" : "DESC";
511
- f = `ORDER BY ${C(e)} ${t}`;
512
+ f = `ORDER BY ${E(e)} ${t}`;
512
513
  }
513
- let p = r * i, m = `LIMIT ${i} OFFSET ${p}`, h = (await x(e, `
514
- SELECT * FROM ${C(c)}.${C(l)}
514
+ let p = r * i, m = `LIMIT ${i} OFFSET ${p}`, h = (await w(e, `
515
+ SELECT * FROM ${E(c)}.${E(l)}
515
516
  WHERE ${d}
516
517
  ${f}
517
518
  ${m}
518
- `)).map(w);
519
+ `)).map(D);
519
520
  if (!a) return {
520
521
  logs: h,
521
522
  start: 0,
522
523
  limit: 0,
523
524
  length: 0
524
525
  };
525
- let g = (await x(e, `
526
- SELECT COUNT(*) as count FROM ${C(c)}.${C(l)}
526
+ let g = (await w(e, `
527
+ SELECT COUNT(*) as count FROM ${E(c)}.${E(l)}
527
528
  WHERE ${d}
528
529
  `))[0]?.count || 0;
529
530
  return {
@@ -536,7 +537,7 @@ function E(e) {
536
537
  }
537
538
  //#endregion
538
539
  //#region src/r2-sql-logs/stats.ts
539
- function se() {
540
+ function le() {
540
541
  return {
541
542
  async getDaily() {
542
543
  throw Error("Stats queries are not supported by R2 SQL logs adapter. Use Analytics Engine or Kysely adapter instead.");
@@ -548,20 +549,20 @@ function se() {
548
549
  }
549
550
  //#endregion
550
551
  //#region src/r2-sql-logs/index.ts
551
- function D(e) {
552
+ function k(e) {
552
553
  let t = !!e.pipelineEndpoint, n = !!e.pipelineBinding;
553
554
  if (!t && !n) throw Error("R2 SQL logs adapter requires one of: \"pipelineEndpoint\" or \"pipelineBinding\"");
554
555
  if (!e.authToken) throw Error("R2 SQL logs adapter requires \"authToken\" configuration");
555
556
  if (!e.warehouseName) throw Error("R2 SQL logs adapter requires \"warehouseName\" configuration");
556
557
  return {
557
- create: re(e),
558
- list: E(e),
559
- get: ae(e)
558
+ create: ie(e),
559
+ list: ce(e),
560
+ get: oe(e)
560
561
  };
561
562
  }
562
563
  //#endregion
563
564
  //#region src/analytics-engine-logs/query.ts
564
- async function O(e, t) {
565
+ async function A(e, t) {
565
566
  let n = e.timeout || 3e4, r = new AbortController(), i = setTimeout(() => r.abort(), n);
566
567
  try {
567
568
  let n = `https://api.cloudflare.com/client/v4/accounts/${e.accountId}/analytics_engine/sql`, i = await fetch(n, {
@@ -584,15 +585,15 @@ async function O(e, t) {
584
585
  clearTimeout(i);
585
586
  }
586
587
  }
587
- function k(e) {
588
+ function j(e) {
588
589
  return `'${e.replace(/'/g, "''").replace(/\\/g, "\\\\")}'`;
589
590
  }
590
- function A(e) {
591
+ function M(e) {
591
592
  return `"${e.replace(/"/g, "\"\"")}"`;
592
593
  }
593
594
  //#endregion
594
595
  //#region src/analytics-engine-logs/logs.ts
595
- function j(e) {
596
+ function N(e) {
596
597
  let t = (e) => {
597
598
  if (e) try {
598
599
  return JSON.parse(e);
@@ -624,16 +625,16 @@ function j(e) {
624
625
  isMobile: e.double1 === 1
625
626
  };
626
627
  }
627
- function ce(e) {
628
+ function ue(e) {
628
629
  return async (t, n) => {
629
- let r = n.log_id || b(), i = {
630
+ let r = n.log_id || C(), i = {
630
631
  ...n,
631
632
  log_id: r
632
633
  };
633
- return le(e, t, i), i;
634
+ return de(e, t, i), i;
634
635
  };
635
636
  }
636
- function le(e, t, n) {
637
+ function de(e, t, n) {
637
638
  if (!e.analyticsEngineBinding) {
638
639
  console.error("Analytics Engine binding not configured");
639
640
  return;
@@ -670,24 +671,24 @@ function le(e, t, n) {
670
671
  console.error("Failed to write log to Analytics Engine:", e);
671
672
  }
672
673
  }
673
- function ue(e) {
674
+ function fe(e) {
674
675
  return async (t, n) => {
675
- let r = await O(e, `
676
+ let r = await A(e, `
676
677
  SELECT *
677
- FROM ${A(e.dataset || "authhero_logs")}
678
- WHERE index1 = ${k(t)}
679
- AND blob1 = ${k(n)}
678
+ FROM ${M(e.dataset || "authhero_logs")}
679
+ WHERE index1 = ${j(t)}
680
+ AND blob1 = ${j(n)}
680
681
  LIMIT 1
681
682
  `);
682
- return r.length === 0 || !r[0] ? null : j(r[0]);
683
+ return r.length === 0 || !r[0] ? null : N(r[0]);
683
684
  };
684
685
  }
685
686
  //#endregion
686
687
  //#region src/analytics-engine-logs/list.ts
687
- function de(e) {
688
+ function pe(e) {
688
689
  return e.replace(/\\([\\"+\-!(){}[\]^~*?:/&|])/g, "$1");
689
690
  }
690
- function fe(e) {
691
+ function me(e) {
691
692
  let t = [], n = "", r = !1;
692
693
  for (let i = 0; i < e.length; i++) {
693
694
  let a = e[i];
@@ -695,20 +696,20 @@ function fe(e) {
695
696
  }
696
697
  return n.trim() && t.push(n.trim()), t;
697
698
  }
698
- function M(e) {
699
+ function P(e) {
699
700
  let t = e;
700
- return t.startsWith("\"") && t.endsWith("\"") && t.length > 1 && (t = t.slice(1, -1)), de(t);
701
+ return t.startsWith("\"") && t.endsWith("\"") && t.length > 1 && (t = t.slice(1, -1)), pe(t);
701
702
  }
702
- function pe(e) {
703
+ function F(e) {
703
704
  let t = {}, n = [];
704
- for (let r of fe(e)) {
705
+ for (let r of me(e)) {
705
706
  if (r === "OR" || r === "AND") continue;
706
707
  let e = r.match(/^(\w+):([\s\S]*)$/);
707
708
  if (e) {
708
- let n = e[1], r = M(e[2]);
709
+ let n = e[1], r = P(e[2]);
709
710
  t[n] || (t[n] = []), t[n].push(r);
710
711
  } else {
711
- let e = M(r);
712
+ let e = P(r);
712
713
  e && n.push(e);
713
714
  }
714
715
  }
@@ -717,7 +718,7 @@ function pe(e) {
717
718
  terms: n
718
719
  };
719
720
  }
720
- function N(e) {
721
+ function I(e) {
721
722
  return {
722
723
  log_id: "blob1",
723
724
  tenant_id: "blob2",
@@ -738,7 +739,7 @@ function N(e) {
738
739
  hostname: "blob17"
739
740
  }[e] || null;
740
741
  }
741
- function me(e) {
742
+ function L(e) {
742
743
  let t = [];
743
744
  for (let [n, r] of Object.entries(e)) {
744
745
  let e = r.filter((e) => e !== "");
@@ -749,41 +750,41 @@ function me(e) {
749
750
  n.length > 0 && t.push(`(${n.join(" OR ")})`);
750
751
  continue;
751
752
  }
752
- let i = N(n);
753
- if (i) if (e.length === 1) t.push(`${i} = ${k(e[0])}`);
753
+ let i = I(n);
754
+ if (i) if (e.length === 1) t.push(`${i} = ${j(e[0])}`);
754
755
  else {
755
- let n = e.map((e) => k(e)).join(", ");
756
+ let n = e.map((e) => j(e)).join(", ");
756
757
  t.push(`${i} IN (${n})`);
757
758
  }
758
759
  }
759
760
  return t;
760
761
  }
761
- function he(e) {
762
+ function R(e) {
762
763
  return e.filter((e) => e !== "").map((e) => {
763
- let t = k(e), n = k(`%${e}%`);
764
+ let t = j(e), n = j(`%${e}%`);
764
765
  return `(blob7 = ${t} OR blob5 LIKE ${n} OR blob4 LIKE ${n})`;
765
766
  });
766
767
  }
767
- function ge(e) {
768
- return e === "date" ? "double2" : N(e) || "timestamp";
768
+ function z(e) {
769
+ return e === "date" ? "double2" : I(e) || "timestamp";
769
770
  }
770
- function P(e) {
771
+ function he(e) {
771
772
  return async (t, n = {}) => {
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)}`];
773
+ 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 = ${j(t)}`];
773
774
  if (s) {
774
- let { fields: e, terms: t } = pe(s);
775
- d.push(...me(e)), d.push(...he(t));
775
+ let { fields: e, terms: t } = F(s);
776
+ d.push(...L(e)), d.push(...R(t));
776
777
  }
777
778
  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}`);
778
779
  let f = d.join(" AND "), p = "ORDER BY timestamp DESC";
779
- o && o.sort_by && (p = `ORDER BY ${ge(o.sort_by)} ${o.sort_order === "asc" ? "ASC" : "DESC"}`);
780
- let m = r * i, h = `LIMIT ${i} OFFSET ${m}`, g = (await O(e, `
780
+ o && o.sort_by && (p = `ORDER BY ${z(o.sort_by)} ${o.sort_order === "asc" ? "ASC" : "DESC"}`);
781
+ let m = r * i, h = `LIMIT ${i} OFFSET ${m}`, g = (await A(e, `
781
782
  SELECT *
782
- FROM ${A(u)}
783
+ FROM ${M(u)}
783
784
  WHERE ${f}
784
785
  ${p}
785
786
  ${h}
786
- `)).map(j);
787
+ `)).map(N);
787
788
  if (!a) return {
788
789
  logs: g,
789
790
  start: 0,
@@ -792,11 +793,11 @@ function P(e) {
792
793
  };
793
794
  let _ = `
794
795
  SELECT count() as count
795
- FROM ${A(u)}
796
+ FROM ${M(u)}
796
797
  WHERE ${f}
797
798
  `;
798
799
  try {
799
- let t = (await O(e, _))[0]?.count || 0;
800
+ let t = (await A(e, _))[0]?.count || 0;
800
801
  return {
801
802
  logs: g,
802
803
  start: m,
@@ -815,11 +816,11 @@ function P(e) {
815
816
  }
816
817
  //#endregion
817
818
  //#region src/analytics-engine-logs/stats.ts
818
- var F = ["s"], I = ["pwd_leak"];
819
- function L(e) {
819
+ var B = ["s"], ge = ["pwd_leak"];
820
+ function V(e) {
820
821
  return `${e.slice(0, 4)}-${e.slice(4, 6)}-${e.slice(6, 8)}`;
821
822
  }
822
- function R(e) {
823
+ function H(e) {
823
824
  return e.toISOString().split("T")[0];
824
825
  }
825
826
  function _e(e) {
@@ -828,17 +829,17 @@ function _e(e) {
828
829
  async getDaily(n, r = {}) {
829
830
  let { from: i, to: a } = r, o = /* @__PURE__ */ new Date(), s = new Date(o);
830
831
  s.setDate(s.getDate() - 30);
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();
832
- return (await O(e, `
832
+ let c = i ? V(i) : H(s), l = a ? V(a) : H(o), u = (/* @__PURE__ */ new Date(`${c}T00:00:00Z`)).getTime(), d = (/* @__PURE__ */ new Date(`${l}T23:59:59.999Z`)).getTime();
833
+ return (await A(e, `
833
834
  SELECT
834
835
  toDate(toDateTime(double2 / 1000)) AS date,
835
- SUM(CASE WHEN blob3 IN (${F.map((e) => k(e)).join(", ")}) THEN 1 ELSE 0 END) AS logins,
836
+ SUM(CASE WHEN blob3 IN (${B.map((e) => j(e)).join(", ")}) THEN 1 ELSE 0 END) AS logins,
836
837
  SUM(CASE WHEN blob3 = 'ss' THEN 1 ELSE 0 END) AS signups,
837
- SUM(CASE WHEN blob3 IN (${I.map((e) => k(e)).join(", ")}) THEN 1 ELSE 0 END) AS leaked_passwords,
838
+ SUM(CASE WHEN blob3 IN (${ge.map((e) => j(e)).join(", ")}) THEN 1 ELSE 0 END) AS leaked_passwords,
838
839
  MIN(double2) AS first_event,
839
840
  MAX(double2) AS last_event
840
841
  FROM "${t}"
841
- WHERE index1 = ${k(n)}
842
+ WHERE index1 = ${j(n)}
842
843
  AND double2 >= ${u}
843
844
  AND double2 <= ${d}
844
845
  GROUP BY date
@@ -855,10 +856,10 @@ function _e(e) {
855
856
  async getActiveUsers(n) {
856
857
  let r = /* @__PURE__ */ new Date();
857
858
  r.setDate(r.getDate() - 30);
858
- let i = r.getTime(), a = F.map((e) => k(e)).join(", "), o = (await O(e, `
859
+ let i = r.getTime(), a = B.map((e) => j(e)).join(", "), o = (await A(e, `
859
860
  SELECT COUNT(DISTINCT blob7) AS count
860
861
  FROM "${t}"
861
- WHERE index1 = ${k(n)}
862
+ WHERE index1 = ${j(n)}
862
863
  AND double2 >= ${i}
863
864
  AND blob3 IN (${a})
864
865
  AND blob7 IS NOT NULL
@@ -962,7 +963,7 @@ var ve = {
962
963
  }
963
964
  };
964
965
  function Se(e, t) {
965
- let n = `toDateTime(intDiv(double2, 1000), ${k(t)})`;
966
+ let n = `toDateTime(intDiv(double2, 1000), ${j(t)})`;
966
967
  switch (e) {
967
968
  case "hour": return `toStartOfHour(${n})`;
968
969
  case "week": return `toStartOfWeek(${n})`;
@@ -974,8 +975,8 @@ function Ce(e) {
974
975
  return e === "hour" ? "DateTime" : "Date";
975
976
  }
976
977
  function we(e, t, n) {
977
- let r = new Date(e.from).getTime(), i = new Date(e.to).getTime(), a = n.map((e) => k(e)).join(", "), o = [
978
- `index1 = ${k(t)}`,
978
+ let r = new Date(e.from).getTime(), i = new Date(e.to).getTime(), a = n.map((e) => j(e)).join(", "), o = [
979
+ `index1 = ${j(t)}`,
979
980
  `double2 >= ${r}`,
980
981
  `double2 < ${i}`,
981
982
  `blob3 IN (${a})`
@@ -983,7 +984,7 @@ function we(e, t, n) {
983
984
  for (let [t, n] of Object.entries(be)) {
984
985
  let r = e.filters[t];
985
986
  if (r && r.length > 0) {
986
- let e = r.map((e) => k(e)).join(", ");
987
+ let e = r.map((e) => j(e)).join(", ");
987
988
  o.push(`${n} IN (${e})`);
988
989
  }
989
990
  }
@@ -992,23 +993,23 @@ function we(e, t, n) {
992
993
  function Te(e, t, n) {
993
994
  if (e.order_by) {
994
995
  let t = e.order_by.startsWith("-");
995
- return `${A(t ? e.order_by.slice(1) : e.order_by)} ${t ? "DESC" : "ASC"}`;
996
+ return `${M(t ? e.order_by.slice(1) : e.order_by)} ${t ? "DESC" : "ASC"}`;
996
997
  }
997
- return t.length > 0 && t[0] === "time" ? `${A("time")} ASC` : `${A(n)} DESC`;
998
+ return t.length > 0 && t[0] === "time" ? `${M("time")} ASC` : `${M(n)} DESC`;
998
999
  }
999
- function z(e) {
1000
+ function U(e) {
1000
1001
  let t = e.dataset || "authhero_logs";
1001
1002
  return { async query(n, r, i) {
1002
1003
  let a = ve[r], o = xe[r], s = [], c = [];
1003
1004
  for (let e of i.group_by) if (e === "time") {
1004
1005
  let e = Se(i.interval, i.tz);
1005
- s.push(`${e} AS ${A("time")}`), c.push({
1006
+ s.push(`${e} AS ${M("time")}`), c.push({
1006
1007
  name: "time",
1007
1008
  type: Ce(i.interval)
1008
1009
  });
1009
1010
  } else {
1010
1011
  let t = ye[e];
1011
- s.push(`${t} AS ${A(e)}`), c.push({
1012
+ s.push(`${t} AS ${M(e)}`), c.push({
1012
1013
  name: e,
1013
1014
  type: "String"
1014
1015
  });
@@ -1017,9 +1018,9 @@ function z(e) {
1017
1018
  name: o.alias,
1018
1019
  type: o.type
1019
1020
  });
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 = `
1021
+ let l = [...s, `${o.expr} AS ${M(o.alias)}`], u = i.group_by.length ? `GROUP BY ${i.group_by.map((e) => M(e === "time" ? "time" : e)).join(", ")}` : "", d = Te(i, i.group_by.map((e) => e === "time" ? "time" : e), o.alias), f = `
1021
1022
  SELECT ${l.join(", ")}
1022
- FROM ${A(t)}
1023
+ FROM ${M(t)}
1023
1024
  WHERE ${we(i, n, a)}
1024
1025
  ${u}
1025
1026
  ORDER BY ${d}
@@ -1057,47 +1058,47 @@ function z(e) {
1057
1058
  }
1058
1059
  //#endregion
1059
1060
  //#region src/analytics-engine-logs/index.ts
1060
- function B(e) {
1061
+ function W(e) {
1061
1062
  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."), {
1062
- create: ce(e),
1063
- list: P(e),
1064
- get: ue(e)
1063
+ create: ue(e),
1064
+ list: he(e),
1065
+ get: fe(e)
1065
1066
  };
1066
1067
  }
1067
1068
  //#endregion
1068
1069
  //#region src/analytics-engine-action-executions/actionExecutions.ts
1069
- var Ee = "authhero_action_executions", De = 1024, Oe = "[truncated]";
1070
- function V(e) {
1070
+ var Ee = "authhero_action_executions", De = 1024, G = "[truncated]";
1071
+ function K(e) {
1071
1072
  if (!(typeof e != "string" || e.length === 0)) try {
1072
1073
  return JSON.parse(e);
1073
1074
  } catch {
1074
1075
  return;
1075
1076
  }
1076
1077
  }
1077
- function ke(t) {
1078
- let n = e.safeParse(t);
1079
- return n.success ? n.data : "unspecified";
1078
+ function Oe(e) {
1079
+ let t = i.safeParse(e);
1080
+ return t.success ? t.data : "unspecified";
1080
1081
  }
1081
- function H(e, t = De) {
1082
- return e.length <= t ? e : `${e.substring(0, t - 11)}${Oe}`;
1082
+ function q(e, t = De) {
1083
+ return e.length <= t ? e : `${e.substring(0, t - 11)}${G}`;
1083
1084
  }
1084
- function U(e) {
1085
+ function J(e) {
1085
1086
  return e == null ? "" : JSON.stringify(e);
1086
1087
  }
1087
- function Ae(e) {
1088
+ function ke(e) {
1088
1089
  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;
1089
1090
  return {
1090
1091
  id: typeof e.blob1 == "string" ? e.blob1 : "",
1091
1092
  tenant_id: typeof e.index1 == "string" ? e.index1 : "",
1092
1093
  trigger_id: typeof e.blob2 == "string" ? e.blob2 : "",
1093
- status: ke(e.blob3),
1094
- results: V(e.blob4) ?? [],
1095
- logs: V(e.blob5),
1094
+ status: Oe(e.blob3),
1095
+ results: K(e.blob4) ?? [],
1096
+ logs: K(e.blob5),
1096
1097
  created_at: t,
1097
1098
  updated_at: n
1098
1099
  };
1099
1100
  }
1100
- function je(e) {
1101
+ function Ae(e) {
1101
1102
  return async (t, n) => {
1102
1103
  let r = Date.now(), i = new Date(r).toISOString(), a = {
1103
1104
  id: n.id,
@@ -1109,10 +1110,10 @@ function je(e) {
1109
1110
  created_at: i,
1110
1111
  updated_at: i
1111
1112
  };
1112
- return Me(e, t, a, r), a;
1113
+ return je(e, t, a, r), a;
1113
1114
  };
1114
1115
  }
1115
- function Me(e, t, n, r) {
1116
+ function je(e, t, n, r) {
1116
1117
  if (!e.analyticsEngineBinding) {
1117
1118
  console.error("Analytics Engine action_executions binding not configured; skipping write");
1118
1119
  return;
@@ -1120,13 +1121,13 @@ function Me(e, t, n, r) {
1120
1121
  try {
1121
1122
  e.analyticsEngineBinding.writeDataPoint({
1122
1123
  blobs: [
1123
- H(n.id),
1124
- H(n.trigger_id),
1125
- H(n.status),
1126
- H(U(n.results)),
1127
- H(U(n.logs)),
1128
- H(n.created_at),
1129
- H(n.updated_at)
1124
+ q(n.id),
1125
+ q(n.trigger_id),
1126
+ q(n.status),
1127
+ q(J(n.results)),
1128
+ q(J(n.logs)),
1129
+ q(n.created_at),
1130
+ q(n.updated_at)
1130
1131
  ],
1131
1132
  doubles: [r],
1132
1133
  indexes: [t.substring(0, 96)]
@@ -1135,29 +1136,29 @@ function Me(e, t, n, r) {
1135
1136
  console.error("Failed to write action_execution to Analytics Engine:", e);
1136
1137
  }
1137
1138
  }
1138
- function Ne(e) {
1139
+ function Me(e) {
1139
1140
  return async (t, n) => {
1140
- let r = await O(e, `
1141
+ let r = await A(e, `
1141
1142
  SELECT *
1142
- FROM ${A(e.dataset || Ee)}
1143
- WHERE index1 = ${k(t)}
1144
- AND blob1 = ${k(n)}
1143
+ FROM ${M(e.dataset || Ee)}
1144
+ WHERE index1 = ${j(t)}
1145
+ AND blob1 = ${j(n)}
1145
1146
  LIMIT 1
1146
1147
  `);
1147
- return r.length === 0 || !r[0] ? null : Ae(r[0]);
1148
+ return r.length === 0 || !r[0] ? null : ke(r[0]);
1148
1149
  };
1149
1150
  }
1150
1151
  //#endregion
1151
1152
  //#region src/analytics-engine-action-executions/index.ts
1152
- function W(e) {
1153
+ function Y(e) {
1153
1154
  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."), {
1154
- create: je(e),
1155
- get: Ne(e)
1155
+ create: Ae(e),
1156
+ get: Me(e)
1156
1157
  };
1157
1158
  }
1158
1159
  //#endregion
1159
1160
  //#region src/geo/index.ts
1160
- function Pe() {
1161
+ function Ne() {
1161
1162
  return { async getGeoInfo(e) {
1162
1163
  try {
1163
1164
  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"];
@@ -1176,7 +1177,7 @@ function Pe() {
1176
1177
  }
1177
1178
  //#endregion
1178
1179
  //#region src/rate-limit/index.ts
1179
- var Fe = class {
1180
+ var Pe = class {
1180
1181
  bindings;
1181
1182
  constructor(e) {
1182
1183
  this.bindings = e;
@@ -1192,12 +1193,12 @@ var Fe = class {
1192
1193
  }
1193
1194
  }
1194
1195
  };
1195
- function G(e) {
1196
- if (e && Object.keys(e).some((t) => e[t])) return new Fe(e);
1196
+ function X(e) {
1197
+ if (e && Object.keys(e).some((t) => e[t])) return new Pe(e);
1197
1198
  }
1198
1199
  //#endregion
1199
1200
  //#region src/code-executor/worker-template.ts
1200
- function K(e) {
1201
+ function Z(e) {
1201
1202
  return `// Auto-generated AuthHero code hook worker
1202
1203
 
1203
1204
  const fnNames = {
@@ -1305,7 +1306,7 @@ export default {
1305
1306
  }
1306
1307
  //#endregion
1307
1308
  //#region src/code-executor/index.ts
1308
- var q = class {
1309
+ var Q = class {
1309
1310
  config;
1310
1311
  constructor(e) {
1311
1312
  this.config = e;
@@ -1366,7 +1367,7 @@ var q = class {
1366
1367
  }
1367
1368
  }
1368
1369
  async deploy(e, t) {
1369
- let n = `hook-${e}`, r = K(t), i = `https://api.cloudflare.com/client/v4/accounts/${this.config.accountId}/workers/dispatch/namespaces/${this.config.dispatchNamespace}/scripts/${n}`, a = JSON.stringify({
1370
+ let n = `hook-${e}`, r = Z(t), i = `https://api.cloudflare.com/client/v4/accounts/${this.config.accountId}/workers/dispatch/namespaces/${this.config.dispatchNamespace}/scripts/${n}`, a = JSON.stringify({
1370
1371
  main_module: "index.js",
1371
1372
  compatibility_date: this.config.compatibilityDate ?? "2024-11-20"
1372
1373
  }), o = new FormData();
@@ -1391,12 +1392,12 @@ var q = class {
1391
1392
  throw Error(`Failed to remove hook worker ${t}: ${r.status} ${e}`);
1392
1393
  }
1393
1394
  }
1394
- }, Ie = q, Le = {
1395
+ }, Fe = Q, Ie = {
1395
1396
  "post-user-login": "onExecutePostLogin",
1396
1397
  "credentials-exchange": "onExecuteCredentialsExchange",
1397
1398
  "pre-user-registration": "onExecutePreUserRegistration",
1398
1399
  "post-user-registration": "onExecutePostUserRegistration"
1399
- }, Re = {
1400
+ }, Le = {
1400
1401
  "post-user-login": {
1401
1402
  accessToken: ["setCustomClaim"],
1402
1403
  idToken: ["setCustomClaim"],
@@ -1415,15 +1416,15 @@ var q = class {
1415
1416
  },
1416
1417
  "post-user-registration": {}
1417
1418
  };
1418
- async function ze(e) {
1419
+ async function Re(e) {
1419
1420
  let t = new TextEncoder().encode(e), n = await crypto.subtle.digest("SHA-256", t), r = new Uint8Array(n), i = "";
1420
1421
  for (let e of r) i += e.toString(16).padStart(2, "0");
1421
1422
  return i;
1422
1423
  }
1423
- function Be(e) {
1424
+ function ze(e) {
1424
1425
  return `
1425
- const TRIGGER_FN_NAMES = ${JSON.stringify(Le)};
1426
- const API_SHAPES = ${JSON.stringify(Re)};
1426
+ const TRIGGER_FN_NAMES = ${JSON.stringify(Ie)};
1427
+ const API_SHAPES = ${JSON.stringify(Le)};
1427
1428
  const MAX_LOG_ENTRIES = 50;
1428
1429
  const MAX_LOG_LENGTH = 500;
1429
1430
 
@@ -1523,7 +1524,7 @@ export default {
1523
1524
  };
1524
1525
  `;
1525
1526
  }
1526
- var Ve = class {
1527
+ var Be = class {
1527
1528
  loader;
1528
1529
  compatibilityDate;
1529
1530
  constructor(e) {
@@ -1532,11 +1533,11 @@ var Ve = class {
1532
1533
  async execute(e) {
1533
1534
  let t = Date.now();
1534
1535
  try {
1535
- let t = Be(e.code), n = {
1536
+ let t = ze(e.code), n = {
1536
1537
  compatibilityDate: this.compatibilityDate,
1537
1538
  mainModule: "hook.js",
1538
1539
  modules: { "hook.js": t }
1539
- }, r = e.hookCodeId ? `${e.hookCodeId}-${await ze(e.code)}` : null;
1540
+ }, r = e.hookCodeId ? `${e.hookCodeId}-${await Re(e.code)}` : null;
1540
1541
  return await (await (r ? this.loader.get(r, async () => n) : this.loader.load(n)).getEntrypoint().fetch(new Request("https://hook/execute", {
1541
1542
  method: "POST",
1542
1543
  headers: { "Content-Type": "application/json" },
@@ -1554,314 +1555,120 @@ var Ve = class {
1554
1555
  };
1555
1556
  }
1556
1557
  }
1557
- }, J = class extends Error {
1558
- status;
1559
- endpoint;
1560
- errors;
1561
- body;
1562
- constructor(e, t, n, 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;
1564
- }
1565
1558
  };
1566
- function He(e, t) {
1567
- return e.length <= t ? e : `${e.slice(0, t)}…`;
1568
- }
1569
- var Y = class {
1570
- accountId;
1571
- apiToken;
1572
- fetchImpl;
1573
- timeoutMs;
1574
- baseUrl;
1575
- constructor(e) {
1576
- this.accountId = e.accountId, this.apiToken = e.apiToken, this.fetchImpl = e.fetch ?? ((...e) => fetch(...e)), this.timeoutMs = e.timeoutMs ?? 3e4, this.baseUrl = (e.baseUrl ?? "https://api.cloudflare.com/client/v4").replace(/\/+$/, "");
1577
- }
1578
- async createD1Database(e) {
1579
- let t = `/accounts/${encodeURIComponent(this.accountId)}/d1/database`;
1580
- return (await this.request("POST", t, { body: JSON.stringify({ name: e }) })).result;
1581
- }
1582
- async listD1Databases(e) {
1583
- let t = e ? `?name=${encodeURIComponent(e)}` : "", n = `/accounts/${encodeURIComponent(this.accountId)}/d1/database${t}`;
1584
- return (await this.request("GET", n)).result ?? [];
1585
- }
1586
- async deleteD1Database(e) {
1587
- let t = `/accounts/${encodeURIComponent(this.accountId)}/d1/database/${encodeURIComponent(e)}`;
1588
- await this.request("DELETE", t);
1589
- }
1590
- async execD1(e, t) {
1591
- let n = `/accounts/${encodeURIComponent(this.accountId)}/d1/database/${encodeURIComponent(e)}/query`;
1592
- return (await this.request("POST", n, { body: JSON.stringify({ sql: t }) })).result ?? [];
1593
- }
1594
- async uploadNamespacedScript(e, t, n) {
1595
- let r = `/accounts/${this.accountId}/workers/dispatch/namespaces/${encodeURIComponent(e)}/scripts/${encodeURIComponent(t)}`, i = {
1596
- main_module: n.mainModule,
1597
- compatibility_date: n.compatibilityDate,
1598
- compatibility_flags: n.compatibilityFlags ?? [],
1599
- bindings: n.bindings ?? [],
1600
- tags: n.tags
1601
- }, a = new FormData();
1602
- a.append("metadata", new Blob([JSON.stringify(i)], { type: "application/json" })), a.append(n.mainModule, new Blob([n.script], { type: "application/javascript+module" }), n.mainModule), await this.request("PUT", r, { body: a });
1603
- }
1604
- async deleteNamespacedScript(e, t) {
1605
- let n = `/accounts/${this.accountId}/workers/dispatch/namespaces/${encodeURIComponent(e)}/scripts/${encodeURIComponent(t)}`;
1606
- await this.request("DELETE", n);
1607
- }
1608
- async setNamespacedScriptSecret(e, t, n, r) {
1609
- let i = `/accounts/${this.accountId}/workers/dispatch/namespaces/${encodeURIComponent(e)}/scripts/${encodeURIComponent(t)}/secrets`;
1610
- await this.request("PUT", i, { body: JSON.stringify({
1611
- name: n,
1612
- text: r,
1613
- type: "secret_text"
1614
- }) });
1615
- }
1616
- async request(e, t, n) {
1617
- let r = `${this.baseUrl}${t}`, i = new AbortController(), a = setTimeout(() => i.abort(), this.timeoutMs), o = {
1618
- Authorization: `Bearer ${this.apiToken}`,
1619
- ...n?.headers ?? {}
1620
- };
1621
- n?.body && !(n.body instanceof FormData) && !o["Content-Type"] && (o["Content-Type"] = "application/json");
1622
- let s;
1623
- try {
1624
- s = await this.fetchImpl(r, {
1625
- method: e,
1626
- headers: o,
1627
- body: n?.body,
1628
- signal: i.signal
1629
- });
1630
- } finally {
1631
- clearTimeout(a);
1632
- }
1633
- let c = await s.text();
1634
- if (!s.ok) {
1635
- let e = [];
1636
- try {
1637
- let t = JSON.parse(c);
1638
- Array.isArray(t.errors) && (e = t.errors);
1639
- } catch {}
1640
- throw new J(s.status, t, c, e);
1641
- }
1642
- if (!(c === "" || s.status === 204)) return JSON.parse(c);
1643
- }
1644
- }, Ue = "{tenant_id}", We = "tenant-{tenant_id}", X = "index.js", Ge = "2026-05-01", Z = 64;
1645
- function Q(e, t) {
1646
- return e.replace(/\{tenant_id\}/g, t);
1647
- }
1648
- function Ke(e) {
1649
- if (!(e instanceof J)) return !1;
1650
- let t = e.body.toLowerCase();
1651
- return e.status === 409 || t.includes("already exists") || t.includes("name is already taken") || t.includes("already in use");
1652
- }
1653
- function $(e) {
1654
- return e instanceof J ? e.status === 404 : !1;
1655
- }
1656
- function qe(e) {
1657
- let t = new Y({
1658
- accountId: e.accountId,
1659
- apiToken: e.apiToken,
1660
- fetch: e.fetch,
1661
- timeoutMs: e.timeoutMs
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;
1663
- async function l(e) {
1664
- let n = (await t.listD1Databases(e)).find((t) => t.name === e);
1665
- if (n) return {
1666
- id: n.uuid,
1667
- created: !1
1668
- };
1669
- try {
1670
- return {
1671
- id: (await t.createD1Database(e)).uuid,
1672
- created: !0
1673
- };
1674
- } catch (n) {
1675
- if (!Ke(n)) throw n;
1676
- let r = (await t.listD1Databases(e)).find((t) => t.name === e);
1677
- if (r) return {
1678
- id: r.uuid,
1679
- created: !1
1680
- };
1681
- throw n;
1682
- }
1683
- }
1684
- let u = "_authhero_provisioner_migrations";
1685
- function d(e, t) {
1686
- let n = [];
1687
- for (let r of e) for (let e of r.results ?? []) if (e && typeof e == "object" && t in e) {
1688
- let r = e[t];
1689
- typeof r == "string" && n.push(r);
1690
- }
1691
- return n;
1692
- }
1693
- async function f(e) {
1694
- return d(await t.execD1(e, `SELECT name FROM sqlite_master WHERE type='table' AND name='${u}';`), "name").length > 0;
1695
- }
1696
- async function p(e) {
1697
- await t.execD1(e, `CREATE TABLE IF NOT EXISTS ${u} (name TEXT PRIMARY KEY, applied_at TEXT NOT NULL);`);
1698
- }
1699
- async function m(e) {
1700
- let n = await t.execD1(e, `SELECT name FROM ${u};`);
1701
- return new Set(d(n, "name"));
1702
- }
1703
- function h(e) {
1704
- return e.replace(/'/g, "''");
1705
- }
1706
- async function g(e, n) {
1707
- let r = (/* @__PURE__ */ new Date()).toISOString();
1708
- await t.execD1(e, `INSERT OR IGNORE INTO ${u} (name, applied_at) VALUES ('${h(n)}', '${h(r)}');`);
1709
- }
1710
- async function _(n) {
1711
- let r = await m(n);
1712
- for (let i of e.migrations) if (!r.has(i.name)) {
1713
- try {
1714
- await t.execD1(n, i.sql);
1715
- } catch (e) {
1716
- throw e instanceof Error ? Error(`Failed to apply migration "${i.name}" to D1 ${n}: ${e.message}`, { cause: e }) : e;
1717
- }
1718
- await g(n, i.name);
1719
- }
1720
- }
1721
- async function v(n, r) {
1722
- let c = [
1723
- {
1724
- type: "d1",
1725
- name: "AUTH_DB",
1726
- id: r
1727
- },
1728
- {
1729
- type: "plain_text",
1730
- name: "CONTROL_PLANE_BASE_URL",
1731
- text: e.controlPlaneBaseUrl
1732
- },
1733
- ...e.extraBindings ?? []
1734
- ];
1735
- await t.uploadNamespacedScript(s, n, {
1736
- script: e.tenantWorkerScript,
1737
- mainModule: i,
1738
- compatibilityDate: a,
1739
- compatibilityFlags: o,
1740
- bindings: c,
1741
- tags: ["authhero-tenant", `tenant:${n}`]
1742
- });
1743
- }
1744
- async function y(n, r) {
1745
- let i = await e.secrets(r);
1746
- for (let [e, r] of Object.entries(i)) await t.setNamespacedScriptSecret(s, n, e, r);
1747
- }
1559
+ //#endregion
1560
+ //#region src/wfp-provisioner/provisioner.ts
1561
+ function Ve(e) {
1562
+ let t = n(e);
1748
1563
  return {
1749
- async onProvision(t) {
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.`);
1752
- let { id: s, created: u } = await l(a), d = u ? !1 : await f(s);
1753
- if (u || d) await p(s), await _(s);
1754
- else {
1755
- c?.warn(`D1 "${a}" has no migration-tracking table — assuming it predates tracking and is fully migrated; backfilling the tracking table and skipping migrations.`), await p(s);
1756
- for (let t of e.migrations) await g(s, t.name);
1757
- }
1758
- return await v(i, s), await y(i, t), {
1564
+ async onProvision(e) {
1565
+ let { scriptName: n, databaseName: r } = t.names(e), { databaseVersion: i, bundleConfiguration: a, workerVersion: o } = t.validate(), { id: s, created: c } = await t.findOrCreateDatabase(r);
1566
+ return await t.applyMigrations(s, c), await t.uploadScript(n, s), await t.uploadSecrets(n, e), {
1759
1567
  d1DatabaseId: s,
1760
- scriptName: i,
1761
- d1Name: a,
1762
- bundleConfiguration: e.bundleConfiguration,
1763
- workerVersion: e.workerVersion,
1764
- databaseVersion: o
1568
+ scriptName: n,
1569
+ d1Name: r,
1570
+ bundleConfiguration: a,
1571
+ workerVersion: o,
1572
+ databaseVersion: i
1765
1573
  };
1766
1574
  },
1767
1575
  async onDeprovision(e) {
1768
- let i = Q(n, e), a = Q(r, e), o = [];
1769
- try {
1770
- await t.deleteNamespacedScript(s, i);
1771
- } catch (e) {
1772
- $(e) || o.push(e);
1773
- }
1774
- try {
1775
- let e = (await t.listD1Databases(a)).find((e) => e.name === a);
1776
- if (e) try {
1777
- await t.deleteD1Database(e.uuid);
1778
- } catch (e) {
1779
- $(e) || o.push(e);
1780
- }
1781
- } catch (e) {
1782
- o.push(e);
1783
- }
1784
- if (o.length > 0) {
1785
- let t = o.map((e) => e instanceof Error ? e.message : String(e)).join("; ");
1786
- throw Error(`Deprovision of tenant "${e}" had ${o.length} failure(s): ${t}`, { cause: o[0] });
1787
- }
1576
+ await t.deprovision(e);
1788
1577
  }
1789
1578
  };
1790
1579
  }
1791
1580
  //#endregion
1792
1581
  //#region src/wfp-provisioner/tenant-hook.ts
1793
- function Je(e) {
1582
+ function He(e) {
1794
1583
  return e.deployment_type === "wfp";
1795
1584
  }
1796
- function Ye(e) {
1797
- if (typeof e != "object" || !e) return [];
1798
- let t = [];
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);
1800
- return t;
1585
+ var Ue = 2048;
1586
+ function $(e) {
1587
+ let t;
1588
+ if (e instanceof Error) t = e.message;
1589
+ else try {
1590
+ t = String(e);
1591
+ } catch {
1592
+ t = Object.prototype.toString.call(e);
1593
+ }
1594
+ return t.slice(0, Ue);
1801
1595
  }
1802
- function Xe(e) {
1803
- let { provisioner: t, tenants: n, syncDefaults: r } = e, i = e.shouldProvision ?? Je, a = e.logger;
1804
- async function o(e, t) {
1805
- let r = t instanceof Error ? t.message : String(t);
1596
+ function We(e) {
1597
+ let { provisioner: t, tenants: n, syncDefaults: i } = e, a = e.shouldProvision ?? He, o = e.logger;
1598
+ async function s(e, t) {
1806
1599
  try {
1807
1600
  await n.update(e, {
1808
1601
  provisioning_state: "failed",
1809
- provisioning_error: r.slice(0, 2048),
1602
+ provisioning_error: $(t),
1810
1603
  provisioning_state_changed_at: (/* @__PURE__ */ new Date()).toISOString()
1811
1604
  });
1812
1605
  } catch (t) {
1813
- a?.warn(`Failed to write provisioning_state="failed" for tenant ${e}:`, t);
1606
+ o?.warn(`Failed to write provisioning_state="failed" for tenant ${e}:`, t);
1814
1607
  }
1815
1608
  }
1816
- async function s(e) {
1817
- let i;
1609
+ async function c(e, a) {
1610
+ let c = async (t, n, r) => {
1611
+ if (a) try {
1612
+ await a(t, n, r);
1613
+ } catch (n) {
1614
+ o?.warn(`Failed to report provisioning step "${t}" for tenant ${e}:`, n);
1615
+ }
1616
+ };
1617
+ await c("provision-resources", "started");
1618
+ let l;
1818
1619
  try {
1819
- i = await t.onProvision(e);
1620
+ l = await t.onProvision(e);
1820
1621
  } catch (t) {
1821
- throw await o(e, t), t;
1622
+ throw await c("provision-resources", "failed", { message: $(t) }), await s(e, t), t;
1822
1623
  }
1823
- let s = {
1824
- d1_database_id: i.d1DatabaseId,
1825
- worker_script_name: i.scriptName,
1826
- bundle_configuration: i.bundleConfiguration,
1827
- worker_version: i.workerVersion,
1828
- database_version: i.databaseVersion
1624
+ let u = {
1625
+ d1_database_id: l.d1DatabaseId,
1626
+ worker_script_name: l.scriptName,
1627
+ bundle_configuration: l.bundleConfiguration,
1628
+ worker_version: l.workerVersion,
1629
+ database_version: l.databaseVersion
1829
1630
  };
1631
+ await c("provision-resources", "succeeded", { ...u });
1830
1632
  try {
1831
- if (r) {
1832
- let t = Ye(await r(e));
1833
- if (t.length > 0) throw Error(`sync-defaults seed reported ${t.length} error(s): ${t.join("; ")}`);
1633
+ if (i) {
1634
+ await c("seed-defaults", "started");
1635
+ try {
1636
+ let t = r(await i(e));
1637
+ if (t.length > 0) throw Error(`sync-defaults seed reported ${t.length} error(s): ${t.join("; ")}`);
1638
+ await c("seed-defaults", "succeeded");
1639
+ } catch (e) {
1640
+ throw await c("seed-defaults", "failed", { message: $(e) }), e;
1641
+ }
1834
1642
  }
1835
1643
  await n.update(e, {
1836
- ...s,
1644
+ ...u,
1837
1645
  provisioning_state: "ready",
1838
1646
  provisioning_error: void 0,
1839
1647
  provisioning_state_changed_at: (/* @__PURE__ */ new Date()).toISOString()
1840
1648
  });
1841
1649
  } catch (t) {
1842
- let r = t instanceof Error ? t.message : String(t);
1843
1650
  try {
1844
1651
  await n.update(e, {
1845
- ...s,
1652
+ ...u,
1846
1653
  provisioning_state: "failed",
1847
- provisioning_error: r.slice(0, 2048),
1654
+ provisioning_error: $(t),
1848
1655
  provisioning_state_changed_at: (/* @__PURE__ */ new Date()).toISOString()
1849
1656
  });
1850
1657
  } catch (t) {
1851
- a?.warn(`Failed to write provisioning_state="failed" for tenant ${e}:`, t);
1658
+ o?.warn(`Failed to write provisioning_state="failed" for tenant ${e}:`, t);
1852
1659
  }
1853
1660
  throw t;
1854
1661
  }
1855
1662
  }
1856
1663
  return {
1857
- async onProvision(e) {
1858
- let t = await n.get(e);
1859
- t && i(t) && await s(e);
1664
+ async onProvision(e, t) {
1665
+ let r = await n.get(e);
1666
+ r && a(r) && await c(e, t);
1860
1667
  },
1861
- async onUpgrade(e) {
1862
- let t = await n.get(e);
1863
- if (!t) throw Error(`Cannot upgrade tenant "${e}": not found.`);
1864
- if (!i(t)) throw Error(`Cannot upgrade tenant "${e}": not a WFP-provisioned tenant.`);
1668
+ async onUpgrade(e, t) {
1669
+ let r = await n.get(e);
1670
+ if (!r) throw Error(`Cannot upgrade tenant "${e}": not found.`);
1671
+ if (!a(r)) throw Error(`Cannot upgrade tenant "${e}": not a WFP-provisioned tenant.`);
1865
1672
  try {
1866
1673
  await n.update(e, {
1867
1674
  provisioning_state: "pending",
@@ -1869,35 +1676,35 @@ function Xe(e) {
1869
1676
  provisioning_state_changed_at: (/* @__PURE__ */ new Date()).toISOString()
1870
1677
  });
1871
1678
  } catch (t) {
1872
- a?.warn(`Failed to write provisioning_state="pending" for tenant ${e}:`, t);
1679
+ o?.warn(`Failed to write provisioning_state="pending" for tenant ${e}:`, t);
1873
1680
  }
1874
- await s(e);
1681
+ await c(e, t);
1875
1682
  },
1876
1683
  async onDeprovision(e) {
1877
1684
  let r = await n.get(e);
1878
- r && !i(r) || await t.onDeprovision(e);
1685
+ r && !a(r) || await t.onDeprovision(e);
1879
1686
  }
1880
1687
  };
1881
1688
  }
1882
1689
  //#endregion
1883
1690
  //#region src/wfp-provisioner/wfp-forward.ts
1884
- var Ze = "DISPATCHER", Qe = "tenant-{tenant_id}-auth";
1885
- function $e(e) {
1691
+ var Ge = "DISPATCHER", Ke = "tenant-{tenant_id}-auth";
1692
+ function qe(e) {
1886
1693
  return typeof e == "object" && !!e && "get" in e && typeof Reflect.get(e, "get") == "function";
1887
1694
  }
1888
- function et(e, t) {
1695
+ function Je(e, t) {
1889
1696
  return e.replace(/\{tenant_id\}/g, t);
1890
1697
  }
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;
1698
+ function Ye(e) {
1699
+ let { tenants: t, controlPlaneTenantId: n, dispatcherBinding: r = Ge, scriptNameTemplate: i = Ke, resolveTenantId: a = (e) => e.req.header("tenant-id") } = e;
1893
1700
  return async (e, o) => {
1894
1701
  let s = await a(e);
1895
1702
  if (!s || s === n) return o();
1896
1703
  let c = await t.get(s);
1897
1704
  if (!c || c.deployment_type !== "wfp" || c.provisioning_state && c.provisioning_state !== "ready") return o();
1898
1705
  let l = Reflect.get(e.env ?? {}, r);
1899
- if (!$e(l)) return o();
1900
- let u = et(i, s), d;
1706
+ if (!qe(l)) return o();
1707
+ let u = Je(i, s), d;
1901
1708
  try {
1902
1709
  d = await l.get(u).fetch(e.req.raw);
1903
1710
  } catch (t) {
@@ -1920,19 +1727,19 @@ function tt(e) {
1920
1727
  }
1921
1728
  //#endregion
1922
1729
  //#region src/index.ts
1923
- function nt(e) {
1730
+ function Xe(e) {
1924
1731
  let t = {
1925
- customDomains: y(e),
1926
- cache: te({
1732
+ customDomains: ee(e),
1733
+ cache: ne({
1927
1734
  ...e.cacheName && { cacheName: e.cacheName },
1928
1735
  ...e.defaultTtlSeconds !== void 0 && { defaultTtlSeconds: e.defaultTtlSeconds },
1929
1736
  ...e.keyPrefix && { keyPrefix: e.keyPrefix }
1930
1737
  }),
1931
- geo: Pe()
1738
+ geo: Ne()
1932
1739
  };
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));
1934
- let n = G(e.rateLimitBindings);
1740
+ e.r2SqlLogs ? t.logs = k(e.r2SqlLogs) : e.analyticsEngineLogs && (t.logs = W(e.analyticsEngineLogs)), e.analyticsEngineLogs && (t.analytics = U(e.analyticsEngineLogs)), e.analyticsEngineActionExecutions && (t.actionExecutions = Y(e.analyticsEngineActionExecutions));
1741
+ let n = X(e.rateLimitBindings);
1935
1742
  return n && (t.rateLimit = n), t;
1936
1743
  }
1937
1744
  //#endregion
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 };
1745
+ export { t as CloudflareApiClient, e as CloudflareApiError, Fe as CloudflareCodeExecutor, Q as DispatchNamespaceCodeExecutor, Be as WorkerLoaderCodeExecutor, Y as createAnalyticsEngineActionExecutionsAdapter, U as createAnalyticsEngineAnalyticsAdapter, W as createAnalyticsEngineLogsAdapter, _e as createAnalyticsEngineStatsAdapter, X as createCloudflareRateLimitAdapter, Ve as createCloudflareWfpD1Provisioner, k as createR2SQLLogsAdapter, le as createR2SQLStatsAdapter, Ye as createWfpForwardMiddleware, We as createWfpTenantProvisioningHook, Xe as default, Z as generateWorkerScript };