@authhero/proxy 0.10.14 → 0.11.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.
- package/dist/proxy.cjs +1 -1
- package/dist/proxy.d.ts +10 -3
- package/dist/proxy.mjs +474 -401
- package/dist/tsconfig.types.tsbuildinfo +1 -1
- package/dist/types/adapter.d.ts +8 -1
- package/dist/types/data-plane/cache.d.ts +2 -2
- package/dist/types/data-plane/handlers/http.d.ts +7 -2
- package/dist/types/data-plane/timeout.d.ts +2 -0
- package/package.json +1 -1
package/dist/proxy.mjs
CHANGED
|
@@ -121,7 +121,7 @@ var h = e.enum([
|
|
|
121
121
|
old: e.unknown(),
|
|
122
122
|
new: e.unknown()
|
|
123
123
|
})).optional()
|
|
124
|
-
}),
|
|
124
|
+
}), v = e.object({
|
|
125
125
|
method: e.string(),
|
|
126
126
|
path: e.string(),
|
|
127
127
|
query: e.record(e.string(), e.string()).optional(),
|
|
@@ -130,17 +130,17 @@ var h = e.enum([
|
|
|
130
130
|
user_agent: e.string().optional(),
|
|
131
131
|
correlation_id: e.string().optional(),
|
|
132
132
|
redirect_uri: e.string().optional()
|
|
133
|
-
}),
|
|
133
|
+
}), y = e.object({
|
|
134
134
|
status_code: e.number(),
|
|
135
135
|
body: e.unknown().optional()
|
|
136
|
-
}),
|
|
136
|
+
}), ee = e.object({
|
|
137
137
|
country_code: e.string(),
|
|
138
138
|
city_name: e.string(),
|
|
139
139
|
latitude: e.string(),
|
|
140
140
|
longitude: e.string(),
|
|
141
141
|
time_zone: e.string(),
|
|
142
142
|
continent_code: e.string()
|
|
143
|
-
}),
|
|
143
|
+
}), te = e.object({
|
|
144
144
|
name: e.string(),
|
|
145
145
|
version: e.string(),
|
|
146
146
|
env: e.record(e.string(), e.string()).optional()
|
|
@@ -153,8 +153,8 @@ e.object({
|
|
|
153
153
|
category: h,
|
|
154
154
|
actor: g,
|
|
155
155
|
target: _,
|
|
156
|
-
request:
|
|
157
|
-
response:
|
|
156
|
+
request: v,
|
|
157
|
+
response: y.optional(),
|
|
158
158
|
connection: e.string().optional(),
|
|
159
159
|
connection_id: e.string().optional(),
|
|
160
160
|
client_name: e.string().optional(),
|
|
@@ -162,8 +162,8 @@ e.object({
|
|
|
162
162
|
strategy_type: e.string().optional(),
|
|
163
163
|
audience: e.string().optional(),
|
|
164
164
|
scope: e.string().optional(),
|
|
165
|
-
location:
|
|
166
|
-
auth0_client:
|
|
165
|
+
location: ee.optional(),
|
|
166
|
+
auth0_client: te.optional(),
|
|
167
167
|
hostname: e.string(),
|
|
168
168
|
is_mobile: e.boolean().optional(),
|
|
169
169
|
timestamp: e.string()
|
|
@@ -178,14 +178,14 @@ e.object({
|
|
|
178
178
|
"SEND_REQUEST",
|
|
179
179
|
"SEND_EMAIL"
|
|
180
180
|
]), e.enum(["VERIFY_EMAIL"]);
|
|
181
|
-
var
|
|
181
|
+
var ne = e.object({
|
|
182
182
|
require_mx_record: e.boolean().optional(),
|
|
183
183
|
block_aliases: e.boolean().optional(),
|
|
184
184
|
block_free_emails: e.boolean().optional(),
|
|
185
185
|
block_disposable_emails: e.boolean().optional(),
|
|
186
186
|
blocklist: e.array(e.string()).optional(),
|
|
187
187
|
allowlist: e.array(e.string()).optional()
|
|
188
|
-
}),
|
|
188
|
+
}), re = e.object({
|
|
189
189
|
id: e.string(),
|
|
190
190
|
alias: e.string().max(100).optional(),
|
|
191
191
|
type: e.literal("AUTH0"),
|
|
@@ -197,7 +197,7 @@ var re = e.object({
|
|
|
197
197
|
user_id: e.string(),
|
|
198
198
|
changes: e.record(e.string(), e.any())
|
|
199
199
|
})
|
|
200
|
-
}),
|
|
200
|
+
}), ie = e.object({
|
|
201
201
|
id: e.string(),
|
|
202
202
|
alias: e.string().max(100).optional(),
|
|
203
203
|
type: e.literal("EMAIL"),
|
|
@@ -206,13 +206,13 @@ var re = e.object({
|
|
|
206
206
|
mask_output: e.boolean().optional(),
|
|
207
207
|
params: e.object({
|
|
208
208
|
email: e.string(),
|
|
209
|
-
rules:
|
|
209
|
+
rules: ne.optional()
|
|
210
210
|
})
|
|
211
|
-
}),
|
|
211
|
+
}), ae = e.enum([
|
|
212
212
|
"change-email",
|
|
213
213
|
"account",
|
|
214
214
|
"custom"
|
|
215
|
-
]),
|
|
215
|
+
]), oe = e.object({
|
|
216
216
|
id: e.string(),
|
|
217
217
|
alias: e.string().max(100).optional(),
|
|
218
218
|
type: e.literal("REDIRECT"),
|
|
@@ -220,17 +220,17 @@ var re = e.object({
|
|
|
220
220
|
allow_failure: e.boolean().optional(),
|
|
221
221
|
mask_output: e.boolean().optional(),
|
|
222
222
|
params: e.object({
|
|
223
|
-
target:
|
|
223
|
+
target: ae.openapi({ description: "The predefined target to redirect to, or 'custom' for a custom URL" }),
|
|
224
224
|
custom_url: e.string().optional().openapi({ description: "Custom URL to redirect to when target is 'custom'" })
|
|
225
225
|
})
|
|
226
|
-
}),
|
|
226
|
+
}), se = e.union([
|
|
227
|
+
re,
|
|
227
228
|
ie,
|
|
228
|
-
|
|
229
|
-
se
|
|
229
|
+
oe
|
|
230
230
|
]);
|
|
231
231
|
e.object({
|
|
232
232
|
name: e.string().min(1).max(150).openapi({ description: "The name of the flow" }),
|
|
233
|
-
actions: e.array(
|
|
233
|
+
actions: e.array(se).optional().default([]).openapi({ description: "The list of actions to execute in sequence" })
|
|
234
234
|
}).extend(n.shape).extend({ id: e.string().openapi({
|
|
235
235
|
description: "Unique identifier for the flow",
|
|
236
236
|
example: "af_12tMpdJ3iek7svMyZkSh5M"
|
|
@@ -247,7 +247,7 @@ e.object({
|
|
|
247
247
|
total: e.number().optional(),
|
|
248
248
|
next: e.string().optional()
|
|
249
249
|
});
|
|
250
|
-
var
|
|
250
|
+
var ce = e.object({
|
|
251
251
|
email: e.string().optional(),
|
|
252
252
|
email_verified: e.boolean().optional(),
|
|
253
253
|
name: e.string().optional(),
|
|
@@ -256,7 +256,7 @@ var le = e.object({
|
|
|
256
256
|
phone_number: e.string().optional(),
|
|
257
257
|
phone_verified: e.boolean().optional(),
|
|
258
258
|
family_name: e.string().optional()
|
|
259
|
-
}).catchall(e.any()),
|
|
259
|
+
}).catchall(e.any()), le = e.object({
|
|
260
260
|
connection: e.string(),
|
|
261
261
|
user_id: e.string(),
|
|
262
262
|
provider: e.string(),
|
|
@@ -269,15 +269,15 @@ var le = e.object({
|
|
|
269
269
|
access_token: e.string().optional(),
|
|
270
270
|
access_token_secret: e.string().optional(),
|
|
271
271
|
refresh_token: e.string().optional(),
|
|
272
|
-
profileData:
|
|
273
|
-
}),
|
|
272
|
+
profileData: ce.optional()
|
|
273
|
+
}), ue = e.object({
|
|
274
274
|
formatted: e.string().optional(),
|
|
275
275
|
street_address: e.string().optional(),
|
|
276
276
|
locality: e.string().optional(),
|
|
277
277
|
region: e.string().optional(),
|
|
278
278
|
postal_code: e.string().optional(),
|
|
279
279
|
country: e.string().optional()
|
|
280
|
-
}).optional(),
|
|
280
|
+
}).optional(), de = e.object({
|
|
281
281
|
email: e.string().transform((e) => e.toLowerCase()).optional(),
|
|
282
282
|
username: e.string().refine((e) => !e.includes("@"), { message: "Usernames must not contain \"@\". Use the email field for email addresses." }).optional(),
|
|
283
283
|
phone_number: e.string().optional(),
|
|
@@ -300,9 +300,9 @@ var le = e.object({
|
|
|
300
300
|
gender: e.string().optional(),
|
|
301
301
|
birthdate: e.string().optional(),
|
|
302
302
|
zoneinfo: e.string().optional(),
|
|
303
|
-
address:
|
|
303
|
+
address: ue
|
|
304
304
|
});
|
|
305
|
-
|
|
305
|
+
de.extend({
|
|
306
306
|
email_verified: e.boolean().default(!1),
|
|
307
307
|
verify_email: e.boolean().optional(),
|
|
308
308
|
last_ip: e.string().optional(),
|
|
@@ -323,24 +323,24 @@ fe.extend({
|
|
|
323
323
|
is_social: e.boolean(),
|
|
324
324
|
email: e.string().optional(),
|
|
325
325
|
login_count: e.number().default(0),
|
|
326
|
-
identities: e.array(
|
|
327
|
-
}).omit({ registration_completed_at: !0 }),
|
|
326
|
+
identities: e.array(le).optional()
|
|
327
|
+
}).omit({ registration_completed_at: !0 }), de.extend({
|
|
328
328
|
login_count: e.number(),
|
|
329
329
|
multifactor: e.array(e.string()).optional(),
|
|
330
330
|
last_ip: e.string().optional(),
|
|
331
331
|
last_login: e.string().optional(),
|
|
332
332
|
user_id: e.string()
|
|
333
333
|
}).catchall(e.any());
|
|
334
|
-
var
|
|
334
|
+
var fe = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", pe = (e = 21) => {
|
|
335
335
|
let t = "", n = crypto.getRandomValues(new Uint8Array(e |= 0));
|
|
336
|
-
for (; e--;) t +=
|
|
336
|
+
for (; e--;) t += fe[n[e] & 63];
|
|
337
337
|
return t;
|
|
338
|
-
},
|
|
338
|
+
}, me = e.object({
|
|
339
339
|
client_id: e.string().optional().openapi({ description: "ID of this client. Generated server-side if omitted (Auth0 behavior)." }),
|
|
340
340
|
name: e.string().min(1).openapi({ description: "Name of this client (min length: 1 character, does not allow < or >)." }),
|
|
341
341
|
description: e.string().max(140).optional().openapi({ description: "Free text description of this client (max length: 140 characters)." }),
|
|
342
342
|
global: e.boolean().default(!1).openapi({ description: "Whether this is your global 'All Applications' client representing legacy tenant settings (true) or a regular client (false)." }),
|
|
343
|
-
client_secret: e.string().default(() =>
|
|
343
|
+
client_secret: e.string().default(() => pe()).optional().openapi({ description: "Client secret (which you must not make public)." }),
|
|
344
344
|
app_type: e.enum([
|
|
345
345
|
"native",
|
|
346
346
|
"spa",
|
|
@@ -457,8 +457,8 @@ var pe = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", me
|
|
|
457
457
|
e.object({
|
|
458
458
|
created_at: e.string(),
|
|
459
459
|
updated_at: e.string()
|
|
460
|
-
}).extend(
|
|
461
|
-
var
|
|
460
|
+
}).extend(me.shape).extend({ client_id: e.string() });
|
|
461
|
+
var he = e.object({
|
|
462
462
|
client_id: e.string().min(1).openapi({ description: "ID of the client." }),
|
|
463
463
|
audience: e.string().min(1).openapi({ description: "The audience (API identifier) of this client grant." }),
|
|
464
464
|
scope: e.array(e.string()).optional().openapi({ description: "Scopes allowed for this client grant." }),
|
|
@@ -471,15 +471,15 @@ var ge = e.object({
|
|
|
471
471
|
is_system: e.boolean().optional().openapi({ description: "If enabled, this grant is a special grant created by Auth0. It cannot be modified or deleted directly." }),
|
|
472
472
|
subject_type: e.enum(["client", "user"]).optional().openapi({ description: "The type of application access the client grant allows. Use of this field is subject to the applicable Free Trial terms in Okta's Master Subscription Agreement." }),
|
|
473
473
|
authorization_details_types: e.array(e.string()).optional().openapi({ description: "Types of authorization_details allowed for this client grant. Use of this field is subject to the applicable Free Trial terms in Okta's Master Subscription Agreement." })
|
|
474
|
-
}),
|
|
474
|
+
}), ge = e.object({ id: e.string().openapi({ description: "ID of the client grant." }) }).extend(he.shape).extend({
|
|
475
475
|
created_at: e.string().optional(),
|
|
476
476
|
updated_at: e.string().optional()
|
|
477
477
|
});
|
|
478
|
-
e.array(
|
|
479
|
-
var
|
|
478
|
+
e.array(ge);
|
|
479
|
+
var _e = e.enum(["iat", "rat"]), ve = e.object({
|
|
480
480
|
id: e.string(),
|
|
481
481
|
token_hash: e.string(),
|
|
482
|
-
type:
|
|
482
|
+
type: _e,
|
|
483
483
|
client_id: e.string().optional(),
|
|
484
484
|
sub: e.string().optional(),
|
|
485
485
|
constraints: e.record(e.string(), e.unknown()).optional(),
|
|
@@ -490,23 +490,23 @@ e.object({
|
|
|
490
490
|
created_at: e.string(),
|
|
491
491
|
used_at: e.string().optional(),
|
|
492
492
|
revoked_at: e.string().optional()
|
|
493
|
-
}).extend(
|
|
494
|
-
var
|
|
493
|
+
}).extend(ve.shape);
|
|
494
|
+
var b = e.object({
|
|
495
495
|
x: e.number(),
|
|
496
496
|
y: e.number()
|
|
497
|
-
}),
|
|
497
|
+
}), ye = /* @__PURE__ */ function(e) {
|
|
498
498
|
return e.RICH_TEXT = "RICH_TEXT", e.NEXT_BUTTON = "NEXT_BUTTON", e.BACK_BUTTON = "BACK_BUTTON", e.SUBMIT_BUTTON = "SUBMIT_BUTTON", e.DIVIDER = "DIVIDER", e.TEXT = "TEXT", e.EMAIL = "EMAIL", e.PASSWORD = "PASSWORD", e.NUMBER = "NUMBER", e.PHONE = "PHONE", e.DATE = "DATE", e.CHECKBOX = "CHECKBOX", e.RADIO = "RADIO", e.SELECT = "SELECT", e.HIDDEN = "HIDDEN", e.LEGAL = "LEGAL", e;
|
|
499
|
-
}({}),
|
|
499
|
+
}({}), be = /* @__PURE__ */ function(e) {
|
|
500
500
|
return e.BLOCK = "BLOCK", e.FIELD = "FIELD", e;
|
|
501
|
-
}({}),
|
|
501
|
+
}({}), x = e.object({
|
|
502
502
|
id: e.string(),
|
|
503
|
-
category: e.nativeEnum(
|
|
504
|
-
type: e.nativeEnum(
|
|
505
|
-
}),
|
|
503
|
+
category: e.nativeEnum(be),
|
|
504
|
+
type: e.nativeEnum(ye)
|
|
505
|
+
}), xe = x.extend({
|
|
506
506
|
category: e.literal("BLOCK"),
|
|
507
507
|
type: e.literal("RICH_TEXT"),
|
|
508
508
|
config: e.object({ content: e.string() }).passthrough()
|
|
509
|
-
}),
|
|
509
|
+
}), Se = x.extend({
|
|
510
510
|
category: e.literal("BLOCK"),
|
|
511
511
|
type: e.union([
|
|
512
512
|
e.literal("NEXT_BUTTON"),
|
|
@@ -514,13 +514,13 @@ var y = e.object({
|
|
|
514
514
|
e.literal("SUBMIT_BUTTON")
|
|
515
515
|
]),
|
|
516
516
|
config: e.object({ text: e.string() }).passthrough()
|
|
517
|
-
}),
|
|
517
|
+
}), Ce = x.extend({
|
|
518
518
|
category: e.literal("FIELD"),
|
|
519
519
|
type: e.literal("LEGAL"),
|
|
520
520
|
required: e.boolean().optional(),
|
|
521
521
|
sensitive: e.boolean().optional(),
|
|
522
522
|
config: e.object({ text: e.string() }).passthrough()
|
|
523
|
-
}),
|
|
523
|
+
}), we = x.extend({
|
|
524
524
|
category: e.literal("FIELD"),
|
|
525
525
|
type: e.union([
|
|
526
526
|
e.literal("TEXT"),
|
|
@@ -540,38 +540,38 @@ var y = e.object({
|
|
|
540
540
|
label: e.string().optional(),
|
|
541
541
|
placeholder: e.string().optional()
|
|
542
542
|
}).passthrough()
|
|
543
|
-
}),
|
|
543
|
+
}), Te = e.object({
|
|
544
544
|
id: e.string(),
|
|
545
545
|
category: e.string(),
|
|
546
546
|
type: e.string()
|
|
547
|
-
}).passthrough(),
|
|
547
|
+
}).passthrough(), Ee = e.union([
|
|
548
|
+
xe,
|
|
548
549
|
Se,
|
|
549
550
|
Ce,
|
|
550
551
|
we,
|
|
551
|
-
Te
|
|
552
|
-
|
|
553
|
-
]), Oe = e.object({
|
|
552
|
+
Te
|
|
553
|
+
]), De = e.object({
|
|
554
554
|
id: e.string(),
|
|
555
555
|
type: e.literal("STEP"),
|
|
556
|
-
coordinates:
|
|
556
|
+
coordinates: b,
|
|
557
557
|
alias: e.string().optional(),
|
|
558
558
|
config: e.object({
|
|
559
|
-
components: e.array(
|
|
559
|
+
components: e.array(Ee),
|
|
560
560
|
next_node: e.string()
|
|
561
561
|
}).passthrough()
|
|
562
|
-
}),
|
|
562
|
+
}), Oe = e.object({
|
|
563
563
|
id: e.string(),
|
|
564
564
|
type: e.literal("FLOW"),
|
|
565
|
-
coordinates:
|
|
565
|
+
coordinates: b,
|
|
566
566
|
alias: e.string().optional(),
|
|
567
567
|
config: e.object({
|
|
568
568
|
flow_id: e.string(),
|
|
569
569
|
next_node: e.string()
|
|
570
570
|
})
|
|
571
|
-
}),
|
|
571
|
+
}), ke = e.object({
|
|
572
572
|
id: e.string(),
|
|
573
573
|
type: e.literal("ACTION"),
|
|
574
|
-
coordinates:
|
|
574
|
+
coordinates: b,
|
|
575
575
|
alias: e.string().optional(),
|
|
576
576
|
config: e.object({
|
|
577
577
|
action_type: e.enum(["REDIRECT"]).openapi({ description: "The type of action to perform" }),
|
|
@@ -583,29 +583,29 @@ var y = e.object({
|
|
|
583
583
|
custom_url: e.string().optional().openapi({ description: "Custom URL when target is 'custom'" }),
|
|
584
584
|
next_node: e.string().openapi({ description: "The next node to navigate to after action (for non-redirect actions)" })
|
|
585
585
|
}).passthrough()
|
|
586
|
-
}),
|
|
586
|
+
}), Ae = e.object({
|
|
587
587
|
id: e.string(),
|
|
588
588
|
type: e.string(),
|
|
589
|
-
coordinates:
|
|
590
|
-
}).passthrough(),
|
|
589
|
+
coordinates: b
|
|
590
|
+
}).passthrough(), je = e.union([
|
|
591
|
+
De,
|
|
591
592
|
Oe,
|
|
592
593
|
ke,
|
|
593
|
-
Ae
|
|
594
|
-
|
|
595
|
-
]), Ne = e.object({
|
|
594
|
+
Ae
|
|
595
|
+
]), Me = e.object({
|
|
596
596
|
next_node: e.string(),
|
|
597
|
-
coordinates:
|
|
598
|
-
}).passthrough(),
|
|
597
|
+
coordinates: b
|
|
598
|
+
}).passthrough(), Ne = e.object({
|
|
599
599
|
resume_flow: e.boolean().optional(),
|
|
600
|
-
coordinates:
|
|
600
|
+
coordinates: b
|
|
601
601
|
}).passthrough();
|
|
602
602
|
e.object({
|
|
603
603
|
id: e.string(),
|
|
604
604
|
name: e.string(),
|
|
605
605
|
languages: e.object({ primary: e.string() }).passthrough(),
|
|
606
|
-
nodes: e.array(
|
|
607
|
-
start:
|
|
608
|
-
ending:
|
|
606
|
+
nodes: e.array(je),
|
|
607
|
+
start: Me,
|
|
608
|
+
ending: Ne,
|
|
609
609
|
created_at: e.string(),
|
|
610
610
|
updated_at: e.string(),
|
|
611
611
|
links: e.object({
|
|
@@ -617,24 +617,24 @@ e.object({
|
|
|
617
617
|
created_at: !0,
|
|
618
618
|
updated_at: !0
|
|
619
619
|
});
|
|
620
|
-
var
|
|
620
|
+
var Pe = /* @__PURE__ */ function(e) {
|
|
621
621
|
return e.TOKEN = "token", e.ID_TOKEN = "id_token", e.TOKEN_ID_TOKEN = "id_token token", e.CODE = "code", e.CODE_ID_TOKEN = "code id_token", e.CODE_TOKEN = "code token", e.CODE_ID_TOKEN_TOKEN = "code id_token token", e;
|
|
622
|
-
}({}),
|
|
622
|
+
}({}), Fe = /* @__PURE__ */ function(e) {
|
|
623
623
|
return e.QUERY = "query", e.FRAGMENT = "fragment", e.FORM_POST = "form_post", e.WEB_MESSAGE = "web_message", e.SAML_POST = "saml_post", e;
|
|
624
624
|
}({}), Ie = /* @__PURE__ */ function(e) {
|
|
625
625
|
return e.S256 = "S256", e.Plain = "plain", e;
|
|
626
|
-
}({}),
|
|
626
|
+
}({}), Le = e.union([e.null(), e.object({
|
|
627
627
|
essential: e.boolean().optional(),
|
|
628
628
|
value: e.unknown().optional(),
|
|
629
629
|
values: e.array(e.unknown()).optional()
|
|
630
|
-
})]).nullable(),
|
|
631
|
-
userinfo: e.record(e.string(),
|
|
632
|
-
id_token: e.record(e.string(),
|
|
633
|
-
}),
|
|
630
|
+
})]).nullable(), Re = e.object({
|
|
631
|
+
userinfo: e.record(e.string(), Le).optional(),
|
|
632
|
+
id_token: e.record(e.string(), Le).optional()
|
|
633
|
+
}), ze = e.object({
|
|
634
634
|
client_id: e.string(),
|
|
635
635
|
act_as: e.string().optional(),
|
|
636
|
-
response_type: e.nativeEnum(
|
|
637
|
-
response_mode: e.nativeEnum(
|
|
636
|
+
response_type: e.nativeEnum(Pe).optional(),
|
|
637
|
+
response_mode: e.nativeEnum(Fe).optional(),
|
|
638
638
|
redirect_uri: e.string().optional(),
|
|
639
639
|
audience: e.string().optional(),
|
|
640
640
|
organization: e.string().optional(),
|
|
@@ -648,7 +648,7 @@ var Fe = /* @__PURE__ */ function(e) {
|
|
|
648
648
|
ui_locales: e.string().optional(),
|
|
649
649
|
max_age: e.number().optional(),
|
|
650
650
|
acr_values: e.string().optional(),
|
|
651
|
-
claims:
|
|
651
|
+
claims: Re.optional(),
|
|
652
652
|
vendor_id: e.string().optional()
|
|
653
653
|
});
|
|
654
654
|
e.object({
|
|
@@ -671,7 +671,7 @@ e.object({
|
|
|
671
671
|
"auto"
|
|
672
672
|
]).optional()
|
|
673
673
|
});
|
|
674
|
-
var
|
|
674
|
+
var Be = e.enum([
|
|
675
675
|
"password_reset",
|
|
676
676
|
"email_verification",
|
|
677
677
|
"otp",
|
|
@@ -685,7 +685,7 @@ e.object({
|
|
|
685
685
|
code_id: e.string().openapi({ description: "The code that will be used in for instance an email verification flow" }),
|
|
686
686
|
login_id: e.string().optional().openapi({ description: "The id of the login session that the code is connected to" }),
|
|
687
687
|
connection_id: e.string().optional().openapi({ description: "The connection that the code is connected to" }),
|
|
688
|
-
code_type:
|
|
688
|
+
code_type: Be,
|
|
689
689
|
code_verifier: e.string().optional().openapi({ description: "The code verifier used in PKCE in outbound flows" }),
|
|
690
690
|
code_challenge: e.string().optional().openapi({ description: "The code challenge used in PKCE in outbound flows" }),
|
|
691
691
|
code_challenge_method: e.enum(["plain", "S256"]).optional().openapi({ description: "The code challenge method used in PKCE in outbound flows" }),
|
|
@@ -697,7 +697,7 @@ e.object({
|
|
|
697
697
|
used_at: e.string().optional(),
|
|
698
698
|
user_id: e.string().optional()
|
|
699
699
|
}).extend({ created_at: e.string() });
|
|
700
|
-
var
|
|
700
|
+
var Ve = e.object({
|
|
701
701
|
kid: e.string().optional(),
|
|
702
702
|
team_id: e.string().optional(),
|
|
703
703
|
realms: e.string().optional(),
|
|
@@ -817,26 +817,26 @@ var Be = e.object({
|
|
|
817
817
|
"never_on_login"
|
|
818
818
|
]).optional()
|
|
819
819
|
});
|
|
820
|
-
function
|
|
820
|
+
function S(e) {
|
|
821
821
|
if (e !== null) {
|
|
822
|
-
if (Array.isArray(e)) return e.filter((e) => e !== null).map(
|
|
822
|
+
if (Array.isArray(e)) return e.filter((e) => e !== null).map(S);
|
|
823
823
|
if (e && typeof e == "object") {
|
|
824
824
|
let t = {};
|
|
825
|
-
for (let [n, r] of Object.entries(e)) r !== null && (t[n] =
|
|
825
|
+
for (let [n, r] of Object.entries(e)) r !== null && (t[n] = S(r));
|
|
826
826
|
return t;
|
|
827
827
|
}
|
|
828
828
|
return e;
|
|
829
829
|
}
|
|
830
830
|
}
|
|
831
|
-
var
|
|
831
|
+
var He = e.object({
|
|
832
832
|
id: e.string().optional(),
|
|
833
833
|
name: e.string(),
|
|
834
834
|
display_name: e.string().optional(),
|
|
835
835
|
strategy: e.string(),
|
|
836
|
-
options: e.preprocess((e) => e === null ? {} :
|
|
836
|
+
options: e.preprocess((e) => e === null ? {} : S(e), Ve).default({}),
|
|
837
837
|
enabled_clients: e.array(e.string()).default([]).optional(),
|
|
838
|
-
response_type: e.nativeEnum(
|
|
839
|
-
response_mode: e.nativeEnum(
|
|
838
|
+
response_type: e.nativeEnum(Pe).optional(),
|
|
839
|
+
response_mode: e.nativeEnum(Fe).optional(),
|
|
840
840
|
is_domain_connection: e.boolean().optional(),
|
|
841
841
|
show_as_button: e.boolean().optional(),
|
|
842
842
|
metadata: e.record(e.string(), e.any()).optional(),
|
|
@@ -846,8 +846,8 @@ e.object({
|
|
|
846
846
|
id: e.string(),
|
|
847
847
|
created_at: e.string().transform((e) => e === null ? "" : e),
|
|
848
848
|
updated_at: e.string().transform((e) => e === null ? "" : e)
|
|
849
|
-
}).extend(
|
|
850
|
-
var
|
|
849
|
+
}).extend(He.shape);
|
|
850
|
+
var Ue = e.object({
|
|
851
851
|
domain: e.string(),
|
|
852
852
|
custom_domain_id: e.string().optional(),
|
|
853
853
|
type: e.enum(["auth0_managed_certs", "self_managed_certs"]),
|
|
@@ -861,7 +861,7 @@ var He = e.object({
|
|
|
861
861
|
"null"
|
|
862
862
|
]).optional(),
|
|
863
863
|
domain_metadata: e.record(e.string(), e.string().max(255)).optional()
|
|
864
|
-
}),
|
|
864
|
+
}), We = e.discriminatedUnion("name", [e.object({
|
|
865
865
|
name: e.literal("txt"),
|
|
866
866
|
record: e.string(),
|
|
867
867
|
domain: e.string()
|
|
@@ -869,7 +869,7 @@ var He = e.object({
|
|
|
869
869
|
name: e.literal("http"),
|
|
870
870
|
http_body: e.string(),
|
|
871
871
|
http_url: e.string()
|
|
872
|
-
})]),
|
|
872
|
+
})]), Ge = Ue.extend({
|
|
873
873
|
custom_domain_id: e.string(),
|
|
874
874
|
primary: e.boolean(),
|
|
875
875
|
status: e.enum([
|
|
@@ -879,28 +879,28 @@ var He = e.object({
|
|
|
879
879
|
"ready"
|
|
880
880
|
]),
|
|
881
881
|
origin_domain_name: e.string().optional(),
|
|
882
|
-
verification: e.object({ methods: e.array(
|
|
882
|
+
verification: e.object({ methods: e.array(We) }).optional(),
|
|
883
883
|
tls_policy: e.string().optional()
|
|
884
884
|
});
|
|
885
|
-
|
|
885
|
+
Ue.pick({
|
|
886
886
|
tls_policy: !0,
|
|
887
887
|
custom_client_ip_header: !0,
|
|
888
888
|
domain_metadata: !0
|
|
889
|
-
}).strict(),
|
|
889
|
+
}).strict(), Ge.extend({ tenant_id: e.string() }), e.object({
|
|
890
890
|
certificate: e.string().regex(/^-----BEGIN CERTIFICATE-----[\s\S]+-----END CERTIFICATE-----\s*$/, "must be PEM-encoded; include the full certificate chain in leaf-first order"),
|
|
891
891
|
private_key: e.string().regex(/-----BEGIN (RSA |EC |ENCRYPTED )?PRIVATE KEY-----[\s\S]+-----END \1PRIVATE KEY-----\s*$/, "must be a PEM-encoded private key")
|
|
892
892
|
});
|
|
893
|
-
var
|
|
893
|
+
var C = e.object({
|
|
894
894
|
id: e.string(),
|
|
895
895
|
order: e.number().optional(),
|
|
896
896
|
visible: e.boolean().optional().default(!0)
|
|
897
|
-
}),
|
|
897
|
+
}), w = C.extend({ category: e.literal("BLOCK").optional() }), Ke = w.extend({
|
|
898
898
|
type: e.literal("DIVIDER"),
|
|
899
899
|
config: e.object({ text: e.string().optional() }).optional()
|
|
900
|
-
}),
|
|
900
|
+
}), qe = w.extend({
|
|
901
901
|
type: e.literal("HTML"),
|
|
902
902
|
config: e.object({ content: e.string().optional() }).optional()
|
|
903
|
-
}),
|
|
903
|
+
}), Je = w.extend({
|
|
904
904
|
type: e.literal("IMAGE"),
|
|
905
905
|
config: e.object({
|
|
906
906
|
src: e.string().optional(),
|
|
@@ -908,43 +908,43 @@ var w = e.object({
|
|
|
908
908
|
width: e.number().optional(),
|
|
909
909
|
height: e.number().optional()
|
|
910
910
|
}).optional()
|
|
911
|
-
}),
|
|
911
|
+
}), Ye = w.extend({
|
|
912
912
|
type: e.literal("JUMP_BUTTON"),
|
|
913
913
|
config: e.object({
|
|
914
914
|
text: e.string().optional(),
|
|
915
915
|
target_step: e.string().optional()
|
|
916
916
|
})
|
|
917
|
-
}),
|
|
917
|
+
}), Xe = w.extend({
|
|
918
918
|
type: e.literal("RESEND_BUTTON"),
|
|
919
919
|
config: e.object({
|
|
920
920
|
text: e.string().optional(),
|
|
921
921
|
resend_action: e.string().optional()
|
|
922
922
|
})
|
|
923
|
-
}),
|
|
923
|
+
}), Ze = w.extend({
|
|
924
924
|
type: e.literal("NEXT_BUTTON"),
|
|
925
925
|
config: e.object({ text: e.string().optional() })
|
|
926
|
-
}),
|
|
926
|
+
}), Qe = w.extend({
|
|
927
927
|
type: e.literal("PREVIOUS_BUTTON"),
|
|
928
928
|
config: e.object({ text: e.string().optional() })
|
|
929
|
-
}),
|
|
929
|
+
}), $e = w.extend({
|
|
930
930
|
type: e.literal("RICH_TEXT"),
|
|
931
931
|
config: e.object({ content: e.string().optional() }).optional()
|
|
932
|
-
}),
|
|
932
|
+
}), T = C.extend({
|
|
933
933
|
category: e.literal("WIDGET").optional(),
|
|
934
934
|
label: e.string().min(1).optional(),
|
|
935
935
|
hint: e.string().min(1).max(500).optional(),
|
|
936
936
|
required: e.boolean().optional(),
|
|
937
937
|
sensitive: e.boolean().optional()
|
|
938
|
-
}),
|
|
938
|
+
}), et = T.extend({
|
|
939
939
|
type: e.literal("AUTH0_VERIFIABLE_CREDENTIALS"),
|
|
940
940
|
config: e.object({ credential_type: e.string().optional() })
|
|
941
|
-
}),
|
|
941
|
+
}), tt = T.extend({
|
|
942
942
|
type: e.literal("GMAPS_ADDRESS"),
|
|
943
943
|
config: e.object({ api_key: e.string().optional() })
|
|
944
|
-
}),
|
|
944
|
+
}), nt = T.extend({
|
|
945
945
|
type: e.literal("RECAPTCHA"),
|
|
946
946
|
config: e.object({ site_key: e.string().optional() })
|
|
947
|
-
}),
|
|
947
|
+
}), E = C.extend({
|
|
948
948
|
category: e.literal("FIELD").optional(),
|
|
949
949
|
label: e.string().min(1).optional(),
|
|
950
950
|
hint: e.string().min(1).max(500).optional(),
|
|
@@ -960,10 +960,10 @@ var w = e.object({
|
|
|
960
960
|
})).optional(),
|
|
961
961
|
required: e.boolean().optional(),
|
|
962
962
|
sensitive: e.boolean().optional()
|
|
963
|
-
}),
|
|
963
|
+
}), rt = E.extend({
|
|
964
964
|
type: e.literal("BOOLEAN"),
|
|
965
965
|
config: e.object({ default_value: e.boolean().optional() }).optional()
|
|
966
|
-
}),
|
|
966
|
+
}), it = E.extend({
|
|
967
967
|
type: e.literal("CARDS"),
|
|
968
968
|
config: e.object({
|
|
969
969
|
options: e.array(e.object({
|
|
@@ -974,7 +974,7 @@ var w = e.object({
|
|
|
974
974
|
})).optional(),
|
|
975
975
|
multi_select: e.boolean().optional()
|
|
976
976
|
}).optional()
|
|
977
|
-
}),
|
|
977
|
+
}), at = E.extend({
|
|
978
978
|
type: e.literal("CHOICE"),
|
|
979
979
|
config: e.object({
|
|
980
980
|
options: e.array(e.object({
|
|
@@ -985,7 +985,7 @@ var w = e.object({
|
|
|
985
985
|
multiple: e.boolean().optional(),
|
|
986
986
|
default_value: e.union([e.string(), e.array(e.string())]).optional()
|
|
987
987
|
}).optional()
|
|
988
|
-
}),
|
|
988
|
+
}), ot = E.extend({
|
|
989
989
|
type: e.literal("CODE"),
|
|
990
990
|
config: e.object({
|
|
991
991
|
length: e.number().int().positive().max(100).optional(),
|
|
@@ -1002,7 +1002,7 @@ var w = e.object({
|
|
|
1002
1002
|
message: "default_value is longer than the configured length",
|
|
1003
1003
|
path: ["default_value"]
|
|
1004
1004
|
}).optional()
|
|
1005
|
-
}),
|
|
1005
|
+
}), st = E.extend({
|
|
1006
1006
|
type: e.literal("CUSTOM"),
|
|
1007
1007
|
config: e.object({
|
|
1008
1008
|
component: e.string().optional(),
|
|
@@ -1010,7 +1010,7 @@ var w = e.object({
|
|
|
1010
1010
|
schema: e.record(e.string(), e.any()).optional(),
|
|
1011
1011
|
code: e.string().optional()
|
|
1012
1012
|
})
|
|
1013
|
-
}),
|
|
1013
|
+
}), ct = E.extend({
|
|
1014
1014
|
type: e.literal("DATE"),
|
|
1015
1015
|
config: e.object({
|
|
1016
1016
|
format: e.string().optional(),
|
|
@@ -1018,7 +1018,7 @@ var w = e.object({
|
|
|
1018
1018
|
max: e.string().optional(),
|
|
1019
1019
|
default_value: e.string().optional()
|
|
1020
1020
|
}).optional()
|
|
1021
|
-
}),
|
|
1021
|
+
}), lt = E.extend({
|
|
1022
1022
|
type: e.literal("DROPDOWN"),
|
|
1023
1023
|
config: e.object({
|
|
1024
1024
|
options: e.array(e.object({
|
|
@@ -1030,7 +1030,7 @@ var w = e.object({
|
|
|
1030
1030
|
multiple: e.boolean().optional(),
|
|
1031
1031
|
default_value: e.union([e.string(), e.array(e.string())]).optional()
|
|
1032
1032
|
}).optional()
|
|
1033
|
-
}),
|
|
1033
|
+
}), ut = E.extend({
|
|
1034
1034
|
type: e.literal("EMAIL"),
|
|
1035
1035
|
config: e.object({
|
|
1036
1036
|
placeholder: e.string().optional(),
|
|
@@ -1038,20 +1038,20 @@ var w = e.object({
|
|
|
1038
1038
|
last_used: e.boolean().optional(),
|
|
1039
1039
|
last_used_label: e.string().optional()
|
|
1040
1040
|
}).optional()
|
|
1041
|
-
}),
|
|
1041
|
+
}), dt = E.extend({
|
|
1042
1042
|
type: e.literal("FILE"),
|
|
1043
1043
|
config: e.object({
|
|
1044
1044
|
accept: e.string().optional(),
|
|
1045
1045
|
max_size: e.number().optional(),
|
|
1046
1046
|
multiple: e.boolean().optional()
|
|
1047
1047
|
}).optional()
|
|
1048
|
-
}),
|
|
1048
|
+
}), ft = E.extend({
|
|
1049
1049
|
type: e.literal("LEGAL"),
|
|
1050
1050
|
config: e.object({
|
|
1051
1051
|
text: e.string(),
|
|
1052
1052
|
html: e.boolean().optional()
|
|
1053
1053
|
}).optional()
|
|
1054
|
-
}),
|
|
1054
|
+
}), pt = E.extend({
|
|
1055
1055
|
type: e.literal("NUMBER"),
|
|
1056
1056
|
config: e.object({
|
|
1057
1057
|
placeholder: e.string().optional(),
|
|
@@ -1060,7 +1060,7 @@ var w = e.object({
|
|
|
1060
1060
|
step: e.number().optional(),
|
|
1061
1061
|
default_value: e.string().optional()
|
|
1062
1062
|
}).optional()
|
|
1063
|
-
}),
|
|
1063
|
+
}), mt = E.extend({
|
|
1064
1064
|
type: e.literal("PASSWORD"),
|
|
1065
1065
|
config: e.object({
|
|
1066
1066
|
placeholder: e.string().optional(),
|
|
@@ -1069,13 +1069,13 @@ var w = e.object({
|
|
|
1069
1069
|
forgot_password_link: e.string().optional(),
|
|
1070
1070
|
default_value: e.string().optional()
|
|
1071
1071
|
}).optional()
|
|
1072
|
-
}),
|
|
1072
|
+
}), ht = E.extend({
|
|
1073
1073
|
type: e.literal("PAYMENT"),
|
|
1074
1074
|
config: e.object({
|
|
1075
1075
|
provider: e.string().optional(),
|
|
1076
1076
|
currency: e.string().optional()
|
|
1077
1077
|
}).optional()
|
|
1078
|
-
}),
|
|
1078
|
+
}), gt = E.extend({
|
|
1079
1079
|
type: e.literal("SOCIAL"),
|
|
1080
1080
|
config: e.object({
|
|
1081
1081
|
providers: e.array(e.string()).optional(),
|
|
@@ -1089,7 +1089,7 @@ var w = e.object({
|
|
|
1089
1089
|
last_used_label: e.string().optional()
|
|
1090
1090
|
})).optional()
|
|
1091
1091
|
}).optional()
|
|
1092
|
-
}),
|
|
1092
|
+
}), _t = E.extend({
|
|
1093
1093
|
type: e.literal("TEL"),
|
|
1094
1094
|
config: e.object({
|
|
1095
1095
|
placeholder: e.string().optional(),
|
|
@@ -1097,7 +1097,7 @@ var w = e.object({
|
|
|
1097
1097
|
default_value: e.string().optional(),
|
|
1098
1098
|
allow_email: e.boolean().optional()
|
|
1099
1099
|
}).optional()
|
|
1100
|
-
}),
|
|
1100
|
+
}), vt = E.extend({
|
|
1101
1101
|
type: e.literal("TEXT"),
|
|
1102
1102
|
config: e.object({
|
|
1103
1103
|
placeholder: e.string().optional(),
|
|
@@ -1107,38 +1107,37 @@ var w = e.object({
|
|
|
1107
1107
|
last_used: e.boolean().optional(),
|
|
1108
1108
|
last_used_label: e.string().optional()
|
|
1109
1109
|
}).optional()
|
|
1110
|
-
}),
|
|
1110
|
+
}), yt = E.extend({
|
|
1111
1111
|
type: e.literal("COUNTRY"),
|
|
1112
1112
|
config: e.object({
|
|
1113
1113
|
placeholder: e.string().optional(),
|
|
1114
1114
|
default_value: e.string().optional()
|
|
1115
1115
|
}).optional()
|
|
1116
|
-
}),
|
|
1116
|
+
}), bt = E.extend({
|
|
1117
1117
|
type: e.literal("URL"),
|
|
1118
1118
|
config: e.object({
|
|
1119
1119
|
placeholder: e.string().optional(),
|
|
1120
1120
|
default_value: e.string().optional()
|
|
1121
1121
|
}).optional()
|
|
1122
|
-
}),
|
|
1123
|
-
Ge,
|
|
1122
|
+
}), xt = e.discriminatedUnion("type", [
|
|
1124
1123
|
Ke,
|
|
1125
1124
|
qe,
|
|
1126
1125
|
Je,
|
|
1127
1126
|
Ye,
|
|
1128
1127
|
Xe,
|
|
1129
1128
|
Ze,
|
|
1130
|
-
Qe
|
|
1131
|
-
|
|
1132
|
-
$e,
|
|
1133
|
-
et,
|
|
1134
|
-
tt
|
|
1129
|
+
Qe,
|
|
1130
|
+
$e
|
|
1135
1131
|
]), St = e.discriminatedUnion("type", [
|
|
1136
|
-
|
|
1132
|
+
et,
|
|
1133
|
+
tt,
|
|
1134
|
+
nt
|
|
1135
|
+
]), Ct = e.discriminatedUnion("type", [
|
|
1137
1136
|
rt,
|
|
1138
1137
|
it,
|
|
1139
1138
|
at,
|
|
1140
|
-
vt,
|
|
1141
1139
|
ot,
|
|
1140
|
+
yt,
|
|
1142
1141
|
st,
|
|
1143
1142
|
ct,
|
|
1144
1143
|
lt,
|
|
@@ -1150,11 +1149,12 @@ var w = e.object({
|
|
|
1150
1149
|
ht,
|
|
1151
1150
|
gt,
|
|
1152
1151
|
_t,
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1152
|
+
vt,
|
|
1153
|
+
bt
|
|
1154
|
+
]), D = e.union([
|
|
1156
1155
|
xt,
|
|
1157
|
-
St
|
|
1156
|
+
St,
|
|
1157
|
+
Ct
|
|
1158
1158
|
]);
|
|
1159
1159
|
new Set([
|
|
1160
1160
|
"BOOLEAN",
|
|
@@ -1213,7 +1213,7 @@ var O = e.object({
|
|
|
1213
1213
|
coordinates: O,
|
|
1214
1214
|
alias: e.string().min(1).max(150).optional(),
|
|
1215
1215
|
config: e.object({
|
|
1216
|
-
components: e.array(
|
|
1216
|
+
components: e.array(D),
|
|
1217
1217
|
next_node: e.string().optional()
|
|
1218
1218
|
})
|
|
1219
1219
|
}), Dt = e.discriminatedUnion("type", [
|
|
@@ -1277,7 +1277,7 @@ 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(
|
|
1280
|
+
components: e.array(D),
|
|
1281
1281
|
messages: e.array(kt).optional(),
|
|
1282
1282
|
links: e.array(At).optional(),
|
|
1283
1283
|
footer: e.string().optional()
|
|
@@ -1485,7 +1485,7 @@ var qt = /* @__PURE__ */ function(e) {
|
|
|
1485
1485
|
e.object({
|
|
1486
1486
|
csrf_token: e.string(),
|
|
1487
1487
|
auth0Client: e.string().optional(),
|
|
1488
|
-
authParams:
|
|
1488
|
+
authParams: ze,
|
|
1489
1489
|
expires_at: e.string(),
|
|
1490
1490
|
deleted_at: e.string().optional(),
|
|
1491
1491
|
ip: e.string().optional(),
|
|
@@ -2730,7 +2730,29 @@ function H(e, t) {
|
|
|
2730
2730
|
let n = new AbortController(), r = setTimeout(() => n.abort(), e);
|
|
2731
2731
|
return t(n.signal).finally(() => clearTimeout(r));
|
|
2732
2732
|
}
|
|
2733
|
-
function
|
|
2733
|
+
function er(e) {
|
|
2734
|
+
let t = e.filter((e) => e !== void 0);
|
|
2735
|
+
if (t.length <= 1) return t[0];
|
|
2736
|
+
if (typeof AbortSignal.any == "function") return AbortSignal.any(t);
|
|
2737
|
+
let n = new AbortController(), r = t.find((e) => e.aborted);
|
|
2738
|
+
if (r) return n.abort(r.reason), n.signal;
|
|
2739
|
+
let i = () => {
|
|
2740
|
+
for (let e of t) e.removeEventListener("abort", i);
|
|
2741
|
+
n.abort(t.find((e) => e.aborted)?.reason);
|
|
2742
|
+
};
|
|
2743
|
+
for (let e of t) e.addEventListener("abort", i);
|
|
2744
|
+
return n.signal;
|
|
2745
|
+
}
|
|
2746
|
+
function U(e, t, n, r) {
|
|
2747
|
+
let i = new AbortController(), a = er([n, i.signal]) ?? i.signal, o, s = new Promise((n, r) => {
|
|
2748
|
+
o = setTimeout(() => {
|
|
2749
|
+
let n = new B(e, t);
|
|
2750
|
+
i.abort(n), r(n);
|
|
2751
|
+
}, e);
|
|
2752
|
+
});
|
|
2753
|
+
return Promise.race([Promise.resolve().then(() => r(a)), s]).finally(() => clearTimeout(o));
|
|
2754
|
+
}
|
|
2755
|
+
function W(e, t, n) {
|
|
2734
2756
|
let r, i = new Promise((e, i) => {
|
|
2735
2757
|
r = setTimeout(() => i(new B(t, n)), t);
|
|
2736
2758
|
});
|
|
@@ -2740,12 +2762,12 @@ function U(e, t, n) {
|
|
|
2740
2762
|
}
|
|
2741
2763
|
//#endregion
|
|
2742
2764
|
//#region src/data-plane/cache.ts
|
|
2743
|
-
var
|
|
2744
|
-
function
|
|
2765
|
+
var tr = 1e4, nr = 8e3;
|
|
2766
|
+
function G(e, t, n) {
|
|
2745
2767
|
let r = typeof t == "number" ? {
|
|
2746
2768
|
freshTtlMs: t,
|
|
2747
2769
|
maxEntries: n
|
|
2748
|
-
} : t, i = r.freshTtlMs, a = r.staleTtlMs ?? 0, o = r.staleIfErrorTtlMs ?? 0, s = r.negativeTtlMs ?? i, c = r.maxEntries ??
|
|
2770
|
+
} : t, i = r.freshTtlMs, a = r.staleTtlMs ?? 0, o = r.staleIfErrorTtlMs ?? 0, s = r.negativeTtlMs ?? i, c = r.maxEntries ?? tr, l = r.waitUntil, u = r.upstreamTimeoutMs ?? nr, d = u > 0 ? u : 1e4, f = /* @__PURE__ */ new Map();
|
|
2749
2771
|
function p(e) {
|
|
2750
2772
|
for (let [t, n] of f) n.stale_if_error_until <= e && n.stale_until <= e && f.delete(t);
|
|
2751
2773
|
for (; f.size >= c;) {
|
|
@@ -2766,42 +2788,41 @@ function W(e, t, n) {
|
|
|
2766
2788
|
function h(e, t) {
|
|
2767
2789
|
return e.refresh_started_at === void 0 ? !1 : t - e.refresh_started_at < d ? !0 : (e.refresh_started_at = void 0, !1);
|
|
2768
2790
|
}
|
|
2769
|
-
function g(t) {
|
|
2770
|
-
|
|
2771
|
-
return u > 0 ? U(n, u, "resolveHost") : n;
|
|
2791
|
+
function g(t, n) {
|
|
2792
|
+
return u > 0 ? U(u, "resolveHost", n, (n) => e.resolveHost(t, { signal: n })) : e.resolveHost(t, { signal: n });
|
|
2772
2793
|
}
|
|
2773
|
-
async function _(e) {
|
|
2774
|
-
let
|
|
2775
|
-
|
|
2794
|
+
async function _(e, t) {
|
|
2795
|
+
let n = f.get(e);
|
|
2796
|
+
n && (n.refresh_started_at = Date.now());
|
|
2776
2797
|
try {
|
|
2777
|
-
let
|
|
2778
|
-
return m(e,
|
|
2798
|
+
let n = await g(e, t);
|
|
2799
|
+
return m(e, n, Date.now()), n;
|
|
2779
2800
|
} catch (t) {
|
|
2780
2801
|
let n = f.get(e);
|
|
2781
2802
|
throw n && (n.refresh_started_at = void 0, n.stale_if_error_until <= Date.now() && f.delete(e)), t;
|
|
2782
2803
|
}
|
|
2783
2804
|
}
|
|
2784
|
-
return { async resolveHost(e) {
|
|
2785
|
-
let
|
|
2786
|
-
if (
|
|
2787
|
-
if (
|
|
2788
|
-
if (f.delete(e), f.set(e,
|
|
2805
|
+
return { async resolveHost(e, t) {
|
|
2806
|
+
let n = Date.now(), r = f.get(e);
|
|
2807
|
+
if (r && r.fresh_until > n) return f.delete(e), f.set(e, r), r.value;
|
|
2808
|
+
if (r && r.stale_until > n) {
|
|
2809
|
+
if (f.delete(e), f.set(e, r), !h(r, n)) {
|
|
2789
2810
|
let t = _(e).catch(() => void 0);
|
|
2790
2811
|
l && l(t);
|
|
2791
2812
|
}
|
|
2792
|
-
return
|
|
2813
|
+
return r.value;
|
|
2793
2814
|
}
|
|
2794
2815
|
try {
|
|
2795
|
-
return await _(e);
|
|
2816
|
+
return await _(e, t?.signal);
|
|
2796
2817
|
} catch (e) {
|
|
2797
|
-
if (
|
|
2818
|
+
if (r && r.stale_if_error_until > n) return r.value;
|
|
2798
2819
|
throw e;
|
|
2799
2820
|
}
|
|
2800
2821
|
} };
|
|
2801
2822
|
}
|
|
2802
2823
|
//#endregion
|
|
2803
2824
|
//#region src/data-plane/registry.ts
|
|
2804
|
-
var
|
|
2825
|
+
var rr = class {
|
|
2805
2826
|
definitions = /* @__PURE__ */ new Map();
|
|
2806
2827
|
bindings;
|
|
2807
2828
|
constructor(e = {}) {
|
|
@@ -2821,23 +2842,20 @@ var nr = class {
|
|
|
2821
2842
|
return n.build(r.data, { bindings: this.bindings });
|
|
2822
2843
|
}
|
|
2823
2844
|
};
|
|
2824
|
-
function
|
|
2845
|
+
function K(e) {
|
|
2825
2846
|
return e;
|
|
2826
2847
|
}
|
|
2827
2848
|
//#endregion
|
|
2828
2849
|
//#region src/data-plane/handlers/util.ts
|
|
2829
|
-
var
|
|
2830
|
-
function cr(e, t) {
|
|
2831
|
-
e.set(rr, t);
|
|
2832
|
-
}
|
|
2833
|
-
function K(e) {
|
|
2834
|
-
return e.get(rr) ?? e.req.raw;
|
|
2835
|
-
}
|
|
2850
|
+
var ir = "__authhero_proxy_request__", ar = "__authhero_proxy_tenant_id__", or = "__authhero_proxy_custom_domain_id__", sr = "__authhero_proxy_domain__", cr = "x-authhero-proxy-mutability-probe";
|
|
2836
2851
|
function lr(e, t) {
|
|
2837
|
-
e.set(ir, t
|
|
2852
|
+
e.set(ir, t);
|
|
2853
|
+
}
|
|
2854
|
+
function q(e) {
|
|
2855
|
+
return e.get(ir) ?? e.req.raw;
|
|
2838
2856
|
}
|
|
2839
|
-
function ur(e) {
|
|
2840
|
-
|
|
2857
|
+
function ur(e, t) {
|
|
2858
|
+
e.set(ar, t.tenant_id), e.set(or, t.custom_domain_id), e.set(sr, t.domain);
|
|
2841
2859
|
}
|
|
2842
2860
|
function dr(e) {
|
|
2843
2861
|
return e.get(ar);
|
|
@@ -2845,14 +2863,17 @@ function dr(e) {
|
|
|
2845
2863
|
function fr(e) {
|
|
2846
2864
|
return e.get(or);
|
|
2847
2865
|
}
|
|
2848
|
-
function pr(e
|
|
2849
|
-
|
|
2850
|
-
t(r), cr(e, new Request(n, { headers: r }));
|
|
2866
|
+
function pr(e) {
|
|
2867
|
+
return e.get(sr);
|
|
2851
2868
|
}
|
|
2852
|
-
function
|
|
2869
|
+
function mr(e, t) {
|
|
2870
|
+
let n = q(e), r = new Headers(n.headers);
|
|
2871
|
+
t(r), lr(e, new Request(n, { headers: r }));
|
|
2872
|
+
}
|
|
2873
|
+
function J(e) {
|
|
2853
2874
|
let t = e.res;
|
|
2854
2875
|
try {
|
|
2855
|
-
t.headers.append(
|
|
2876
|
+
t.headers.append(cr, "1"), t.headers.delete(cr);
|
|
2856
2877
|
return;
|
|
2857
2878
|
} catch {
|
|
2858
2879
|
e.res = new Response(t.body, {
|
|
@@ -2864,7 +2885,7 @@ function q(e) {
|
|
|
2864
2885
|
}
|
|
2865
2886
|
//#endregion
|
|
2866
2887
|
//#region src/data-plane/handlers/cors.ts
|
|
2867
|
-
var
|
|
2888
|
+
var hr = e.object({
|
|
2868
2889
|
origins: e.array(e.string()).optional(),
|
|
2869
2890
|
allow_credentials: e.boolean().optional(),
|
|
2870
2891
|
allow_headers: e.array(e.string()).optional(),
|
|
@@ -2872,44 +2893,44 @@ var mr = e.object({
|
|
|
2872
2893
|
expose_headers: e.array(e.string()).optional(),
|
|
2873
2894
|
max_age: e.number().int().optional()
|
|
2874
2895
|
}).refine((e) => !(e.allow_credentials && e.origins?.includes("*")), { message: "Cannot use wildcard origin (*) with allow_credentials" });
|
|
2875
|
-
function
|
|
2896
|
+
function gr(e, t) {
|
|
2876
2897
|
let n = new Headers(), r = e.origins ?? ["*"], i = r.includes("*");
|
|
2877
2898
|
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;
|
|
2878
2899
|
}
|
|
2879
|
-
var
|
|
2900
|
+
var _r = K({
|
|
2880
2901
|
type: "cors",
|
|
2881
|
-
optionsSchema:
|
|
2902
|
+
optionsSchema: hr,
|
|
2882
2903
|
build(e) {
|
|
2883
2904
|
return async (t, n) => {
|
|
2884
2905
|
let r = t.req.header("origin") ?? null;
|
|
2885
2906
|
if (t.req.method === "OPTIONS" && r !== null && t.req.header("access-control-request-method") !== void 0) {
|
|
2886
|
-
let t =
|
|
2907
|
+
let t = gr(e, r);
|
|
2887
2908
|
return new Response(null, {
|
|
2888
2909
|
status: 204,
|
|
2889
2910
|
headers: t
|
|
2890
2911
|
});
|
|
2891
2912
|
}
|
|
2892
2913
|
await n();
|
|
2893
|
-
let i =
|
|
2894
|
-
|
|
2914
|
+
let i = gr(e, r);
|
|
2915
|
+
J(t), i.forEach((e, n) => {
|
|
2895
2916
|
n.toLowerCase() === "vary" ? t.res.headers.append(n, e) : t.res.headers.set(n, e);
|
|
2896
2917
|
});
|
|
2897
2918
|
};
|
|
2898
2919
|
}
|
|
2899
|
-
}),
|
|
2920
|
+
}), vr = e.object({
|
|
2900
2921
|
username: e.string(),
|
|
2901
2922
|
password: e.string(),
|
|
2902
2923
|
realm: e.string().optional()
|
|
2903
2924
|
});
|
|
2904
|
-
function
|
|
2925
|
+
function yr(e, t) {
|
|
2905
2926
|
let n = `${e}:${t}`;
|
|
2906
2927
|
return typeof btoa == "function" ? btoa(n) : Buffer.from(n, "utf-8").toString("base64");
|
|
2907
2928
|
}
|
|
2908
|
-
var
|
|
2929
|
+
var br = K({
|
|
2909
2930
|
type: "basic_auth",
|
|
2910
|
-
optionsSchema:
|
|
2931
|
+
optionsSchema: vr,
|
|
2911
2932
|
build(e) {
|
|
2912
|
-
let t =
|
|
2933
|
+
let t = yr(e.username, e.password), n = (e.realm ?? "Restricted").replace(/["\\\r\n]/g, "");
|
|
2913
2934
|
return async (e, r) => {
|
|
2914
2935
|
let i = e.req.header("authorization");
|
|
2915
2936
|
if (i) {
|
|
@@ -2925,7 +2946,7 @@ var yr = G({
|
|
|
2925
2946
|
});
|
|
2926
2947
|
};
|
|
2927
2948
|
}
|
|
2928
|
-
}),
|
|
2949
|
+
}), xr = K({
|
|
2929
2950
|
type: "headers",
|
|
2930
2951
|
optionsSchema: e.object({
|
|
2931
2952
|
request: e.record(e.string(), e.string()).optional(),
|
|
@@ -2935,23 +2956,23 @@ var yr = G({
|
|
|
2935
2956
|
}),
|
|
2936
2957
|
build(e) {
|
|
2937
2958
|
return async (t, n) => {
|
|
2938
|
-
if ((e.request || e.remove_request) &&
|
|
2959
|
+
if ((e.request || e.remove_request) && mr(t, (t) => {
|
|
2939
2960
|
if (e.remove_request?.forEach((e) => t.delete(e)), e.request) for (let [n, r] of Object.entries(e.request)) t.set(n, r);
|
|
2940
|
-
}), await n(), (e.response || e.remove_response) && (
|
|
2961
|
+
}), await n(), (e.response || e.remove_response) && (J(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);
|
|
2941
2962
|
};
|
|
2942
2963
|
}
|
|
2943
|
-
}),
|
|
2964
|
+
}), Sr = K({
|
|
2944
2965
|
type: "cache",
|
|
2945
2966
|
optionsSchema: e.object({ ttl_seconds: e.number().int().positive() }),
|
|
2946
2967
|
build(e) {
|
|
2947
2968
|
return async (t, n) => {
|
|
2948
2969
|
if (await n(), !t.res.headers.has("Cache-Control")) {
|
|
2949
2970
|
let n = t.res.headers.has("set-cookie") ? "private" : "public";
|
|
2950
|
-
|
|
2971
|
+
J(t), t.res.headers.set("Cache-Control", `${n}, max-age=${e.ttl_seconds}`);
|
|
2951
2972
|
}
|
|
2952
2973
|
};
|
|
2953
2974
|
}
|
|
2954
|
-
}),
|
|
2975
|
+
}), Cr = [
|
|
2955
2976
|
"173.245.48.0/20",
|
|
2956
2977
|
"103.21.244.0/22",
|
|
2957
2978
|
"103.22.200.0/22",
|
|
@@ -2975,7 +2996,7 @@ var yr = G({
|
|
|
2975
2996
|
"2a06:98c0::/29",
|
|
2976
2997
|
"2c0f:f248::/32"
|
|
2977
2998
|
];
|
|
2978
|
-
function
|
|
2999
|
+
function wr(e) {
|
|
2979
3000
|
let t = e.split(".");
|
|
2980
3001
|
if (t.length !== 4) return null;
|
|
2981
3002
|
let n = [];
|
|
@@ -2987,14 +3008,14 @@ function Cr(e) {
|
|
|
2987
3008
|
}
|
|
2988
3009
|
return n;
|
|
2989
3010
|
}
|
|
2990
|
-
function
|
|
3011
|
+
function Tr(e) {
|
|
2991
3012
|
if (e === "") return [];
|
|
2992
3013
|
let t = e.split(":"), n = [];
|
|
2993
3014
|
for (let e = 0; e < t.length; e++) {
|
|
2994
3015
|
let r = t[e];
|
|
2995
3016
|
if (r.includes(".")) {
|
|
2996
3017
|
if (e !== t.length - 1) return null;
|
|
2997
|
-
let i =
|
|
3018
|
+
let i = wr(r);
|
|
2998
3019
|
if (!i) return null;
|
|
2999
3020
|
n.push(i[0] << 8 | i[1], i[2] << 8 | i[3]);
|
|
3000
3021
|
continue;
|
|
@@ -3004,14 +3025,14 @@ function wr(e) {
|
|
|
3004
3025
|
}
|
|
3005
3026
|
return n;
|
|
3006
3027
|
}
|
|
3007
|
-
function
|
|
3028
|
+
function Er(e) {
|
|
3008
3029
|
let t = e.split("::");
|
|
3009
3030
|
if (t.length > 2) return null;
|
|
3010
|
-
let n =
|
|
3031
|
+
let n = Tr(t[0] ?? "");
|
|
3011
3032
|
if (!n) return null;
|
|
3012
3033
|
let r;
|
|
3013
3034
|
if (t.length === 2) {
|
|
3014
|
-
let e =
|
|
3035
|
+
let e = Tr(t[1] ?? "");
|
|
3015
3036
|
if (!e) return null;
|
|
3016
3037
|
let i = 8 - n.length - e.length;
|
|
3017
3038
|
if (i < 1) return null;
|
|
@@ -3026,25 +3047,25 @@ function Tr(e) {
|
|
|
3026
3047
|
for (let e of r) i.push(e >> 8 & 255, e & 255);
|
|
3027
3048
|
return i;
|
|
3028
3049
|
}
|
|
3029
|
-
function
|
|
3050
|
+
function Dr(e) {
|
|
3030
3051
|
let t = e.trim();
|
|
3031
3052
|
t.startsWith("[") && t.endsWith("]") && (t = t.slice(1, -1));
|
|
3032
3053
|
let n = t.indexOf("%");
|
|
3033
3054
|
if (n !== -1 && (t = t.slice(0, n)), t === "") return null;
|
|
3034
|
-
if (!t.includes(":")) return
|
|
3035
|
-
let r =
|
|
3055
|
+
if (!t.includes(":")) return wr(t);
|
|
3056
|
+
let r = Er(t);
|
|
3036
3057
|
return r ? r.slice(0, 10).every((e) => e === 0) && r[10] === 255 && r[11] === 255 ? r.slice(12) : r : null;
|
|
3037
3058
|
}
|
|
3038
|
-
function
|
|
3039
|
-
let [t, n] = e.split("/"), r =
|
|
3059
|
+
function Or(e) {
|
|
3060
|
+
let [t, n] = e.split("/"), r = Dr(t ?? ""), i = Number(n);
|
|
3040
3061
|
if (!r || !Number.isInteger(i)) throw Error(`Invalid Cloudflare CIDR: ${e}`);
|
|
3041
3062
|
return {
|
|
3042
3063
|
bytes: r,
|
|
3043
3064
|
prefixBits: i
|
|
3044
3065
|
};
|
|
3045
3066
|
}
|
|
3046
|
-
var
|
|
3047
|
-
function
|
|
3067
|
+
var kr = Cr.map(Or);
|
|
3068
|
+
function Ar(e, t) {
|
|
3048
3069
|
if (e.length !== t.bytes.length) return !1;
|
|
3049
3070
|
let n = t.prefixBits >> 3;
|
|
3050
3071
|
for (let r = 0; r < n; r++) if (e[r] !== t.bytes[r]) return !1;
|
|
@@ -3053,11 +3074,11 @@ function kr(e, t) {
|
|
|
3053
3074
|
let i = 255 << 8 - r & 255;
|
|
3054
3075
|
return (e[n] & i) === (t.bytes[n] & i);
|
|
3055
3076
|
}
|
|
3056
|
-
function
|
|
3057
|
-
let t =
|
|
3058
|
-
return t ?
|
|
3077
|
+
function jr(e) {
|
|
3078
|
+
let t = Dr(e);
|
|
3079
|
+
return t ? kr.some((e) => Ar(t, e)) : !1;
|
|
3059
3080
|
}
|
|
3060
|
-
var
|
|
3081
|
+
var Mr = K({
|
|
3061
3082
|
type: "forwarded_headers",
|
|
3062
3083
|
optionsSchema: e.object({
|
|
3063
3084
|
client_ip_header: e.string().default("cf-connecting-ip"),
|
|
@@ -3068,46 +3089,46 @@ var jr = G({
|
|
|
3068
3089
|
build(e) {
|
|
3069
3090
|
return async (t, n) => {
|
|
3070
3091
|
let r = new URL(t.req.url);
|
|
3071
|
-
|
|
3092
|
+
mr(t, (n) => {
|
|
3072
3093
|
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);
|
|
3073
|
-
let i = n.get(e.client_ip_header), a = i && e.skip_cloudflare_client_ip &&
|
|
3094
|
+
let i = n.get(e.client_ip_header), a = i && e.skip_cloudflare_client_ip && jr(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;
|
|
3074
3095
|
n.set("x-forwarded-for", l), e.set_x_real_ip && n.set("x-real-ip", s);
|
|
3075
3096
|
}), await n();
|
|
3076
3097
|
};
|
|
3077
3098
|
}
|
|
3078
|
-
}),
|
|
3079
|
-
function
|
|
3099
|
+
}), Nr = e.object({ upstream_host: e.string().optional() });
|
|
3100
|
+
function Pr(e) {
|
|
3080
3101
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
3081
3102
|
}
|
|
3082
|
-
function
|
|
3103
|
+
function Fr(e) {
|
|
3083
3104
|
if (typeof e.getSetCookie == "function") return e.getSetCookie();
|
|
3084
3105
|
let t = [];
|
|
3085
3106
|
return e.forEach((e, n) => {
|
|
3086
3107
|
n.toLowerCase() === "set-cookie" && t.push(e);
|
|
3087
3108
|
}), t;
|
|
3088
3109
|
}
|
|
3089
|
-
var
|
|
3110
|
+
var Ir = K({
|
|
3090
3111
|
type: "rewrite_cookies",
|
|
3091
|
-
optionsSchema:
|
|
3112
|
+
optionsSchema: Nr,
|
|
3092
3113
|
build(e) {
|
|
3093
3114
|
return async (t, n) => {
|
|
3094
3115
|
await n();
|
|
3095
3116
|
let r = new URL(t.req.url).hostname, i = e.upstream_host ?? t.get("__proxy_upstream_host__");
|
|
3096
3117
|
if (!i) return;
|
|
3097
|
-
let a =
|
|
3118
|
+
let a = Fr(t.res.headers);
|
|
3098
3119
|
if (a.length === 0) return;
|
|
3099
|
-
let o =
|
|
3100
|
-
|
|
3120
|
+
let o = Pr(i), s = RegExp(`(?:^|;\\s*)Domain=\\.?${o}(?=;|$)`, "i");
|
|
3121
|
+
J(t), t.res.headers.delete("set-cookie");
|
|
3101
3122
|
for (let e of a) t.res.headers.append("set-cookie", e.replace(s, `Domain=${r}`));
|
|
3102
3123
|
};
|
|
3103
3124
|
}
|
|
3104
|
-
}),
|
|
3125
|
+
}), Lr = K({
|
|
3105
3126
|
type: "rewrite_location",
|
|
3106
3127
|
optionsSchema: e.object({ upstream_origin: e.string().optional() }),
|
|
3107
3128
|
build(e) {
|
|
3108
3129
|
return async (t, n) => {
|
|
3109
3130
|
if (await n(), t.res.headers.has("x-authhero-preserve-location")) {
|
|
3110
|
-
|
|
3131
|
+
J(t), t.res.headers.delete($n);
|
|
3111
3132
|
return;
|
|
3112
3133
|
}
|
|
3113
3134
|
let r = t.res.status;
|
|
@@ -3124,10 +3145,10 @@ var Fr = G({
|
|
|
3124
3145
|
}
|
|
3125
3146
|
if (o.origin !== a) return;
|
|
3126
3147
|
let s = new URL(t.req.url), c = `${`${s.protocol}//${s.host}`}${o.pathname}${o.search}${o.hash}`;
|
|
3127
|
-
|
|
3148
|
+
J(t), t.res.headers.set("location", c);
|
|
3128
3149
|
};
|
|
3129
3150
|
}
|
|
3130
|
-
}),
|
|
3151
|
+
}), Rr = new Set([
|
|
3131
3152
|
"connection",
|
|
3132
3153
|
"keep-alive",
|
|
3133
3154
|
"proxy-authenticate",
|
|
@@ -3136,45 +3157,92 @@ var Fr = G({
|
|
|
3136
3157
|
"trailers",
|
|
3137
3158
|
"transfer-encoding",
|
|
3138
3159
|
"upgrade"
|
|
3139
|
-
]),
|
|
3160
|
+
]), zr = 3e4, Br = e.object({
|
|
3140
3161
|
upstream_url: e.string(),
|
|
3141
3162
|
preserve_host: e.boolean().default(!1),
|
|
3142
3163
|
timeout_ms: e.number().int().positive().optional()
|
|
3143
3164
|
});
|
|
3144
|
-
function
|
|
3165
|
+
function Vr(e, t) {
|
|
3145
3166
|
return e === "" || e === "/" ? t : `${e.endsWith("/") ? e.slice(0, -1) : e}${t.startsWith("/") ? t : `/${t}`}`;
|
|
3146
3167
|
}
|
|
3147
|
-
function
|
|
3168
|
+
function Hr(e) {
|
|
3148
3169
|
return e !== "GET" && e !== "HEAD";
|
|
3149
3170
|
}
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3171
|
+
var Ur = 128 * 1024;
|
|
3172
|
+
function Wr(e) {
|
|
3173
|
+
let t = e.headers.get("content-length");
|
|
3174
|
+
if (t === null) return null;
|
|
3175
|
+
let n = Number(t);
|
|
3176
|
+
return Number.isInteger(n) && n >= 0 ? n : null;
|
|
3177
|
+
}
|
|
3178
|
+
async function Gr(e, t) {
|
|
3179
|
+
let n = e.getReader(), r = !1, i = setTimeout(() => {
|
|
3180
|
+
r = !0, n.cancel().catch(() => {});
|
|
3181
|
+
}, t), a = [], o = 0;
|
|
3182
|
+
try {
|
|
3183
|
+
for (;;) {
|
|
3184
|
+
let { done: e, value: i } = await n.read();
|
|
3185
|
+
if (r) throw new B(t, "Request body read");
|
|
3186
|
+
if (e) break;
|
|
3187
|
+
a.push(i), o += i.byteLength;
|
|
3188
|
+
}
|
|
3189
|
+
} finally {
|
|
3190
|
+
clearTimeout(i);
|
|
3191
|
+
}
|
|
3192
|
+
let s = new Uint8Array(o), c = 0;
|
|
3193
|
+
for (let e of a) s.set(e, c), c += e.byteLength;
|
|
3194
|
+
return s.buffer;
|
|
3195
|
+
}
|
|
3196
|
+
function Kr(e) {
|
|
3197
|
+
return V(e) ? new Response("Request body timeout", {
|
|
3198
|
+
status: 408,
|
|
3199
|
+
headers: { "x-authhero-proxy-error": "request_body_timeout" }
|
|
3200
|
+
}) : new Response("Bad request", {
|
|
3201
|
+
status: 400,
|
|
3202
|
+
headers: { "x-authhero-proxy-error": "request_body_failed" }
|
|
3203
|
+
});
|
|
3204
|
+
}
|
|
3205
|
+
async function qr(e, t, n) {
|
|
3206
|
+
if (!Hr(e.method) || !e.body) return;
|
|
3207
|
+
let r = Wr(e);
|
|
3208
|
+
if (r === null || r > Ur) return e.body;
|
|
3209
|
+
let i = await Gr(e.body, n);
|
|
3210
|
+
return t.set("content-length", String(i.byteLength)), i;
|
|
3211
|
+
}
|
|
3212
|
+
async function Jr(e, t, n) {
|
|
3213
|
+
let r = new URL(t.url), i = new URL(e.upstream_url);
|
|
3214
|
+
i.pathname = Vr(i.pathname, r.pathname), i.search = r.search;
|
|
3215
|
+
let a = new Headers(t.headers);
|
|
3216
|
+
for (let e of Rr) a.delete(e);
|
|
3217
|
+
e.preserve_host || a.set("host", i.host), a.has("x-forwarded-host") || a.set("x-forwarded-host", r.host), a.has("x-forwarded-proto") || a.set("x-forwarded-proto", r.protocol.replace(":", ""));
|
|
3218
|
+
let o = await qr(t, a, n), s = {
|
|
3157
3219
|
method: t.method,
|
|
3158
|
-
headers:
|
|
3159
|
-
body:
|
|
3220
|
+
headers: a,
|
|
3221
|
+
body: o,
|
|
3160
3222
|
redirect: "manual"
|
|
3161
3223
|
};
|
|
3162
|
-
return
|
|
3163
|
-
target:
|
|
3164
|
-
init:
|
|
3224
|
+
return o instanceof ReadableStream && (s.duplex = "half"), {
|
|
3225
|
+
target: i,
|
|
3226
|
+
init: s
|
|
3165
3227
|
};
|
|
3166
3228
|
}
|
|
3167
|
-
var
|
|
3229
|
+
var Yr = K({
|
|
3168
3230
|
type: "http",
|
|
3169
|
-
optionsSchema:
|
|
3231
|
+
optionsSchema: Br,
|
|
3170
3232
|
build(e) {
|
|
3171
|
-
let t = e.timeout_ms ??
|
|
3233
|
+
let t = e.timeout_ms ?? zr;
|
|
3172
3234
|
return async (n) => {
|
|
3173
|
-
let
|
|
3174
|
-
n.set("__proxy_upstream_host__", r.hostname), n.set("__proxy_upstream_origin__", `${r.protocol}//${r.host}`);
|
|
3235
|
+
let r = q(n), i;
|
|
3175
3236
|
try {
|
|
3176
|
-
|
|
3177
|
-
|
|
3237
|
+
i = await Jr(e, r, t);
|
|
3238
|
+
} catch (e) {
|
|
3239
|
+
return Kr(e);
|
|
3240
|
+
}
|
|
3241
|
+
let { target: a, init: o } = i;
|
|
3242
|
+
n.set("__proxy_upstream_host__", a.hostname), n.set("__proxy_upstream_origin__", `${a.protocol}//${a.host}`);
|
|
3243
|
+
try {
|
|
3244
|
+
return await H(t, (e) => fetch(a.toString(), {
|
|
3245
|
+
...o,
|
|
3178
3246
|
signal: e
|
|
3179
3247
|
}));
|
|
3180
3248
|
} catch (e) {
|
|
@@ -3182,31 +3250,37 @@ var Ur = G({
|
|
|
3182
3250
|
}
|
|
3183
3251
|
};
|
|
3184
3252
|
}
|
|
3185
|
-
}),
|
|
3253
|
+
}), Xr = 3e4, Zr = e.object({
|
|
3186
3254
|
binding: e.string(),
|
|
3187
3255
|
upstream_url: e.string().optional(),
|
|
3188
3256
|
preserve_host: e.boolean().default(!0),
|
|
3189
3257
|
timeout_ms: e.number().int().positive().optional()
|
|
3190
3258
|
});
|
|
3191
|
-
function
|
|
3259
|
+
function Qr(e) {
|
|
3192
3260
|
return typeof e == "object" && !!e && typeof e.fetch == "function";
|
|
3193
3261
|
}
|
|
3194
|
-
var
|
|
3262
|
+
var $r = K({
|
|
3195
3263
|
type: "service_binding",
|
|
3196
|
-
optionsSchema:
|
|
3264
|
+
optionsSchema: Zr,
|
|
3197
3265
|
build(e, t) {
|
|
3198
3266
|
let n = t.bindings[e.binding];
|
|
3199
|
-
if (!
|
|
3200
|
-
let r = e.upstream_url ?? `https://${e.binding}.binding.invalid/`, i = e.timeout_ms ??
|
|
3267
|
+
if (!Qr(n)) throw Error(`Service binding "${e.binding}" is not configured or is not a Fetcher`);
|
|
3268
|
+
let r = e.upstream_url ?? `https://${e.binding}.binding.invalid/`, i = e.timeout_ms ?? Xr;
|
|
3201
3269
|
return async (t) => {
|
|
3202
|
-
let a =
|
|
3203
|
-
upstream_url: r,
|
|
3204
|
-
preserve_host: e.preserve_host
|
|
3205
|
-
}, a);
|
|
3206
|
-
t.set("__proxy_upstream_host__", o.hostname), t.set("__proxy_upstream_origin__", `${o.protocol}//${o.host}`);
|
|
3270
|
+
let a = q(t), o;
|
|
3207
3271
|
try {
|
|
3208
|
-
|
|
3209
|
-
|
|
3272
|
+
o = await Jr({
|
|
3273
|
+
upstream_url: r,
|
|
3274
|
+
preserve_host: e.preserve_host
|
|
3275
|
+
}, a, i);
|
|
3276
|
+
} catch (e) {
|
|
3277
|
+
return Kr(e);
|
|
3278
|
+
}
|
|
3279
|
+
let { target: s, init: c } = o;
|
|
3280
|
+
t.set("__proxy_upstream_host__", s.hostname), t.set("__proxy_upstream_origin__", `${s.protocol}//${s.host}`);
|
|
3281
|
+
try {
|
|
3282
|
+
return await H(i, async (e) => n.fetch(new Request(s.toString(), {
|
|
3283
|
+
...c,
|
|
3210
3284
|
signal: e
|
|
3211
3285
|
})));
|
|
3212
3286
|
} catch (e) {
|
|
@@ -3214,35 +3288,35 @@ var qr = G({
|
|
|
3214
3288
|
}
|
|
3215
3289
|
};
|
|
3216
3290
|
}
|
|
3217
|
-
}),
|
|
3291
|
+
}), ei = 3e4, ti = e.object({
|
|
3218
3292
|
binding: e.string(),
|
|
3219
3293
|
script_name: e.string(),
|
|
3220
3294
|
cpu_ms: e.number().int().positive().optional(),
|
|
3221
3295
|
subrequests: e.number().int().positive().optional(),
|
|
3222
3296
|
timeout_ms: e.number().int().positive().optional()
|
|
3223
3297
|
});
|
|
3224
|
-
function
|
|
3298
|
+
function ni(e) {
|
|
3225
3299
|
return typeof e == "object" && !!e && typeof e.get == "function";
|
|
3226
3300
|
}
|
|
3227
|
-
var
|
|
3228
|
-
function
|
|
3229
|
-
return
|
|
3301
|
+
var Y = /\{(tenant_id|custom_domain_id|domain|host)\}/g;
|
|
3302
|
+
function ri(e) {
|
|
3303
|
+
return Y.lastIndex = 0, Y.test(e);
|
|
3230
3304
|
}
|
|
3231
|
-
var
|
|
3305
|
+
var ii = K({
|
|
3232
3306
|
type: "dispatch_namespace",
|
|
3233
|
-
optionsSchema:
|
|
3307
|
+
optionsSchema: ti,
|
|
3234
3308
|
build(e, t) {
|
|
3235
3309
|
let n = t.bindings[e.binding];
|
|
3236
|
-
if (!
|
|
3237
|
-
let r =
|
|
3310
|
+
if (!ni(n)) throw Error(`Dispatch namespace binding "${e.binding}" is not configured or does not expose .get()`);
|
|
3311
|
+
let r = ri(e.script_name), i = e.timeout_ms ?? ei, a = e.cpu_ms || e.subrequests ? { limits: {
|
|
3238
3312
|
...e.cpu_ms ? { cpuMs: e.cpu_ms } : {},
|
|
3239
3313
|
...e.subrequests ? { subrequests: e.subrequests } : {}
|
|
3240
3314
|
} } : void 0;
|
|
3241
3315
|
return async (t) => {
|
|
3242
3316
|
let o = e.script_name;
|
|
3243
3317
|
if (r) {
|
|
3244
|
-
let n =
|
|
3245
|
-
if (o = o.replace(
|
|
3318
|
+
let n = dr(t), r = fr(t), i = pr(t), a = t.req.header("host") ?? t.req.header("x-forwarded-host") ?? "";
|
|
3319
|
+
if (o = o.replace(Y, (e, t) => {
|
|
3246
3320
|
switch (t) {
|
|
3247
3321
|
case "tenant_id": return n ?? "";
|
|
3248
3322
|
case "custom_domain_id": return r ?? "";
|
|
@@ -3252,7 +3326,7 @@ var Qr = G({
|
|
|
3252
3326
|
}
|
|
3253
3327
|
}), o.includes("{") || o === "") return t.text(`dispatch_namespace: could not resolve script name from template "${e.script_name}"`, 500);
|
|
3254
3328
|
}
|
|
3255
|
-
let s =
|
|
3329
|
+
let s = q(t);
|
|
3256
3330
|
try {
|
|
3257
3331
|
let e = n.get(o, void 0, a);
|
|
3258
3332
|
return await H(i, async (t) => {
|
|
@@ -3264,7 +3338,7 @@ var Qr = G({
|
|
|
3264
3338
|
}
|
|
3265
3339
|
};
|
|
3266
3340
|
}
|
|
3267
|
-
}),
|
|
3341
|
+
}), ai = K({
|
|
3268
3342
|
type: "redirect",
|
|
3269
3343
|
optionsSchema: e.object({
|
|
3270
3344
|
upstream_url: e.string().refine((e) => {
|
|
@@ -3293,7 +3367,7 @@ var Qr = G({
|
|
|
3293
3367
|
});
|
|
3294
3368
|
};
|
|
3295
3369
|
}
|
|
3296
|
-
}),
|
|
3370
|
+
}), oi = K({
|
|
3297
3371
|
type: "static",
|
|
3298
3372
|
optionsSchema: e.object({
|
|
3299
3373
|
status: e.number().int().default(200),
|
|
@@ -3313,15 +3387,15 @@ var Qr = G({
|
|
|
3313
3387
|
});
|
|
3314
3388
|
//#endregion
|
|
3315
3389
|
//#region src/data-plane/handlers/index.ts
|
|
3316
|
-
function
|
|
3317
|
-
e.add(
|
|
3390
|
+
function si(e) {
|
|
3391
|
+
e.add(_r).add(br).add(xr).add(Sr).add(Mr).add(Ir).add(Lr).add(Yr).add($r).add(ii).add(ai).add(oi);
|
|
3318
3392
|
}
|
|
3319
3393
|
//#endregion
|
|
3320
3394
|
//#region src/data-plane/matcher.ts
|
|
3321
|
-
function
|
|
3395
|
+
function ci(e) {
|
|
3322
3396
|
return [...e].sort((e, t) => e.priority === t.priority ? e.created_at.localeCompare(t.created_at) : e.priority - t.priority);
|
|
3323
3397
|
}
|
|
3324
|
-
function
|
|
3398
|
+
function li(e, t) {
|
|
3325
3399
|
let n = e.toLowerCase(), r = t.toLowerCase();
|
|
3326
3400
|
if (n === r) return !0;
|
|
3327
3401
|
if (n.startsWith("*.")) {
|
|
@@ -3330,13 +3404,13 @@ function ri(e, t) {
|
|
|
3330
3404
|
}
|
|
3331
3405
|
return !1;
|
|
3332
3406
|
}
|
|
3333
|
-
function
|
|
3334
|
-
return !e || e.length === 0 ? !0 : e.some((e) =>
|
|
3407
|
+
function ui(e, t) {
|
|
3408
|
+
return !e || e.length === 0 ? !0 : e.some((e) => li(e, t));
|
|
3335
3409
|
}
|
|
3336
|
-
function
|
|
3410
|
+
function di(e) {
|
|
3337
3411
|
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;
|
|
3338
3412
|
return async (e, i) => {
|
|
3339
|
-
if (r && !
|
|
3413
|
+
if (r && !ui(r, e.req.header("host") ?? "")) return new Response("No matching route", { status: 404 });
|
|
3340
3414
|
for (let [n, r] of t) {
|
|
3341
3415
|
let t = e.req.header(n);
|
|
3342
3416
|
if (t === void 0 || !r.test(t)) return new Response("No matching route", { status: 404 });
|
|
@@ -3353,17 +3427,17 @@ function ai(e) {
|
|
|
3353
3427
|
}
|
|
3354
3428
|
//#endregion
|
|
3355
3429
|
//#region src/data-plane/compile.ts
|
|
3356
|
-
var
|
|
3357
|
-
function
|
|
3430
|
+
var fi = "forwarded_headers";
|
|
3431
|
+
function pi(e) {
|
|
3358
3432
|
return e.some((e) => e.type === "forwarded_headers") ? [...e] : [{
|
|
3359
|
-
type:
|
|
3433
|
+
type: fi,
|
|
3360
3434
|
options: {}
|
|
3361
3435
|
}, ...e];
|
|
3362
3436
|
}
|
|
3363
|
-
function
|
|
3364
|
-
return e.has("forwarded_headers") ?
|
|
3437
|
+
function X(e, t) {
|
|
3438
|
+
return e.has("forwarded_headers") ? pi(t) : [...t];
|
|
3365
3439
|
}
|
|
3366
|
-
var
|
|
3440
|
+
var mi = [
|
|
3367
3441
|
"GET",
|
|
3368
3442
|
"POST",
|
|
3369
3443
|
"PUT",
|
|
@@ -3372,45 +3446,45 @@ var ci = [
|
|
|
3372
3446
|
"OPTIONS",
|
|
3373
3447
|
"HEAD"
|
|
3374
3448
|
];
|
|
3375
|
-
function
|
|
3449
|
+
function Z(e, n, r, i) {
|
|
3376
3450
|
let a = new t();
|
|
3377
3451
|
r && a.use("*", async (e, t) => {
|
|
3378
|
-
|
|
3452
|
+
ur(e, r), await t();
|
|
3379
3453
|
});
|
|
3380
|
-
let o =
|
|
3454
|
+
let o = ci(e);
|
|
3381
3455
|
for (let e of o) {
|
|
3382
3456
|
let t = [];
|
|
3383
|
-
t.push(
|
|
3384
|
-
for (let r of
|
|
3385
|
-
let r = e.match.methods?.length ? e.match.methods.map((e) => e.toUpperCase()) :
|
|
3457
|
+
t.push(di(e.match));
|
|
3458
|
+
for (let r of X(n, e.handlers)) t.push(n.build(r.type, r.options));
|
|
3459
|
+
let r = e.match.methods?.length ? e.match.methods.map((e) => e.toUpperCase()) : mi, i = e.match.path || "/*";
|
|
3386
3460
|
a.on(r, [i], ...t);
|
|
3387
3461
|
}
|
|
3388
|
-
return i && i.length > 0 ? a.on(
|
|
3462
|
+
return i && i.length > 0 ? a.on(mi, ["*"], ...i) : a.all("*", (e) => e.text("No matching route", 404)), a.onError((e, t) => {
|
|
3389
3463
|
let n = V(e);
|
|
3390
3464
|
return t.text(n ? "Upstream timeout" : "Bad gateway", n ? 504 : 502, { "x-authhero-proxy-error": n ? "handler_timeout" : "handler_failed" });
|
|
3391
3465
|
}), a;
|
|
3392
3466
|
}
|
|
3393
3467
|
//#endregion
|
|
3394
3468
|
//#region src/data-plane/router.ts
|
|
3395
|
-
var
|
|
3396
|
-
function
|
|
3397
|
-
return e.resolver ? e.resolver : e.cache ?
|
|
3469
|
+
var hi = 1e4;
|
|
3470
|
+
function gi(e) {
|
|
3471
|
+
return e.resolver ? e.resolver : e.cache ? G(e.data, e.cache) : G(e.data, e.cacheTtlMs ?? 3e4);
|
|
3398
3472
|
}
|
|
3399
|
-
function
|
|
3473
|
+
function _i(e) {
|
|
3400
3474
|
if (e.registry) return e.registry;
|
|
3401
|
-
let t = new
|
|
3402
|
-
return
|
|
3475
|
+
let t = new rr(e.bindings ?? {});
|
|
3476
|
+
return si(t), t;
|
|
3403
3477
|
}
|
|
3404
|
-
function
|
|
3405
|
-
let t =
|
|
3478
|
+
function Q(e) {
|
|
3479
|
+
let t = gi(e), n = _i(e), r = /* @__PURE__ */ new WeakMap(), i = e.resolveHostTimeoutMs ?? hi, 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
3480
|
return async (e) => {
|
|
3407
3481
|
let s = e.req.header("host") ?? e.req.header("x-forwarded-host");
|
|
3408
3482
|
if (!s) return e.text("Missing host", 400);
|
|
3409
3483
|
try {
|
|
3410
|
-
let c = await U(t.resolveHost(s
|
|
3484
|
+
let c = await U(i, "resolveHost", void 0, (e) => t.resolveHost(s, { signal: e }));
|
|
3411
3485
|
if (!c) return o ? await o.fetch(e.req.raw) : e.text("Unknown host", 404);
|
|
3412
3486
|
let l = r.get(c);
|
|
3413
|
-
return l || (l =
|
|
3487
|
+
return l || (l = Z(c.routes, n, {
|
|
3414
3488
|
tenant_id: c.tenant_id,
|
|
3415
3489
|
custom_domain_id: c.custom_domain_id,
|
|
3416
3490
|
domain: c.domain
|
|
@@ -3420,15 +3494,15 @@ function Z(e) {
|
|
|
3420
3494
|
}
|
|
3421
3495
|
};
|
|
3422
3496
|
}
|
|
3423
|
-
function
|
|
3497
|
+
function vi(e) {
|
|
3424
3498
|
let n = new t();
|
|
3425
|
-
return n.all("*",
|
|
3499
|
+
return n.all("*", Q(e)), n;
|
|
3426
3500
|
}
|
|
3427
3501
|
//#endregion
|
|
3428
3502
|
//#region src/app.ts
|
|
3429
|
-
function
|
|
3503
|
+
function yi(e) {
|
|
3430
3504
|
let n = new t();
|
|
3431
|
-
return n.all("*",
|
|
3505
|
+
return n.all("*", Q({
|
|
3432
3506
|
data: e.data,
|
|
3433
3507
|
cacheTtlMs: e.cacheTtlMs,
|
|
3434
3508
|
cache: e.cache,
|
|
@@ -3444,110 +3518,109 @@ function pi(e) {
|
|
|
3444
3518
|
}
|
|
3445
3519
|
//#endregion
|
|
3446
3520
|
//#region src/data-plane/cache-api-cache.ts
|
|
3447
|
-
var
|
|
3448
|
-
function
|
|
3521
|
+
var bi = 1e3, xi = 1e3;
|
|
3522
|
+
function Si(e, t) {
|
|
3449
3523
|
return new Request(`https://proxy-cache.internal/${encodeURIComponent(e)}/hosts/${encodeURIComponent(t.toLowerCase())}`, { method: "GET" });
|
|
3450
3524
|
}
|
|
3451
|
-
function
|
|
3525
|
+
function Ci() {
|
|
3452
3526
|
return globalThis.caches?.default;
|
|
3453
3527
|
}
|
|
3454
|
-
function
|
|
3455
|
-
let t = e.cache ??
|
|
3528
|
+
function wi(e) {
|
|
3529
|
+
let t = e.cache ?? Ci();
|
|
3456
3530
|
if (!t) return e.upstream;
|
|
3457
|
-
let n = t, r = e.namespace ?? "authhero-proxy", i = e.cacheTtlSeconds ?? 60, a = e.negativeCacheTtlSeconds ?? 10, o = e.waitUntil, s = e.cacheReadTimeoutMs ??
|
|
3531
|
+
let n = t, r = e.namespace ?? "authhero-proxy", i = e.cacheTtlSeconds ?? 60, a = e.negativeCacheTtlSeconds ?? 10, o = e.waitUntil, s = e.cacheReadTimeoutMs ?? bi, c = e.cacheWriteTimeoutMs ?? xi;
|
|
3458
3532
|
async function l(e) {
|
|
3459
3533
|
try {
|
|
3460
|
-
return await
|
|
3534
|
+
return await W(Promise.resolve(n.match(e)), s, "cache.match");
|
|
3461
3535
|
} catch {
|
|
3462
3536
|
return;
|
|
3463
3537
|
}
|
|
3464
3538
|
}
|
|
3465
|
-
return { async resolveHost(t) {
|
|
3466
|
-
let
|
|
3467
|
-
if (
|
|
3468
|
-
return (await
|
|
3539
|
+
return { async resolveHost(t, s) {
|
|
3540
|
+
let u = Si(r, t), d = await l(u);
|
|
3541
|
+
if (d) try {
|
|
3542
|
+
return (await d.json()).value;
|
|
3469
3543
|
} catch {}
|
|
3470
|
-
let
|
|
3544
|
+
let f = await e.upstream.resolveHost(t, s), p = f === null ? a : i, m = new Response(JSON.stringify({ value: f }), { headers: {
|
|
3471
3545
|
"content-type": "application/json",
|
|
3472
|
-
"cache-control": `public, max-age=${
|
|
3473
|
-
} }),
|
|
3474
|
-
return o ? o(
|
|
3546
|
+
"cache-control": `public, max-age=${p}`
|
|
3547
|
+
} }), h = W(Promise.resolve(n.put(u, m)), c, "cache.put").catch(() => void 0);
|
|
3548
|
+
return o ? o(h) : await h, f;
|
|
3475
3549
|
} };
|
|
3476
3550
|
}
|
|
3477
|
-
function
|
|
3478
|
-
return
|
|
3551
|
+
function Ti(e, t) {
|
|
3552
|
+
return Si(e, t);
|
|
3479
3553
|
}
|
|
3480
3554
|
//#endregion
|
|
3481
3555
|
//#region src/data-plane/cache-adapter-cache.ts
|
|
3482
|
-
var
|
|
3483
|
-
function
|
|
3484
|
-
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 =
|
|
3556
|
+
var Ei = 1e3, Di = 1e3, Oi = 5e3;
|
|
3557
|
+
function ki(e) {
|
|
3558
|
+
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 = Ei, cacheWriteTimeoutMs: u = Di, upstreamTimeoutMs: d = Oi } = e, f = d > 0 ? d : 1e4, p = /* @__PURE__ */ new Map();
|
|
3485
3559
|
function m(e) {
|
|
3486
3560
|
return `${s}:${e.toLowerCase()}`;
|
|
3487
3561
|
}
|
|
3488
3562
|
async function h(e) {
|
|
3489
3563
|
try {
|
|
3490
|
-
return await
|
|
3564
|
+
return await W(n.get(e), l, "cache.get") ?? null;
|
|
3491
3565
|
} catch {
|
|
3492
3566
|
return null;
|
|
3493
3567
|
}
|
|
3494
3568
|
}
|
|
3495
3569
|
function g(e, t, r) {
|
|
3496
|
-
let i =
|
|
3570
|
+
let i = W(Promise.resolve().then(() => n.set(e, t, r)), u, "cache.set").catch(() => void 0);
|
|
3497
3571
|
return c ? (c(i), Promise.resolve()) : i;
|
|
3498
3572
|
}
|
|
3499
3573
|
function _(e, t) {
|
|
3500
3574
|
let n = p.get(e);
|
|
3501
3575
|
return n === void 0 ? !1 : t - n < f ? !0 : (p.delete(e), !1);
|
|
3502
3576
|
}
|
|
3503
|
-
function
|
|
3504
|
-
|
|
3505
|
-
return d > 0 ? U(n, d, "resolveHost") : n;
|
|
3577
|
+
function v(e, n) {
|
|
3578
|
+
return d > 0 ? U(d, "resolveHost", n, (n) => t.resolveHost(e, { signal: n })) : t.resolveHost(e, { signal: n });
|
|
3506
3579
|
}
|
|
3507
|
-
async function
|
|
3580
|
+
async function y(e, t) {
|
|
3508
3581
|
return p.set(e, Date.now()), (async () => {
|
|
3509
3582
|
try {
|
|
3510
|
-
let
|
|
3511
|
-
value:
|
|
3512
|
-
freshUntilMs:
|
|
3513
|
-
staleUntilMs:
|
|
3514
|
-
staleIfErrorUntilMs:
|
|
3515
|
-
},
|
|
3516
|
-
return await g(m(e),
|
|
3583
|
+
let n = await v(e, t), s = Date.now(), c = n === null ? o : r, l = n === null ? 0 : i, u = n === null ? 0 : a, d = {
|
|
3584
|
+
value: n,
|
|
3585
|
+
freshUntilMs: s + c,
|
|
3586
|
+
staleUntilMs: s + c + l,
|
|
3587
|
+
staleIfErrorUntilMs: s + c + l + u
|
|
3588
|
+
}, f = Math.max(1, Math.ceil((c + l + u) / 1e3));
|
|
3589
|
+
return await g(m(e), d, f), n;
|
|
3517
3590
|
} finally {
|
|
3518
3591
|
p.delete(e);
|
|
3519
3592
|
}
|
|
3520
3593
|
})();
|
|
3521
3594
|
}
|
|
3522
|
-
return { async resolveHost(e) {
|
|
3523
|
-
let
|
|
3524
|
-
if (
|
|
3525
|
-
if (
|
|
3526
|
-
if (
|
|
3527
|
-
if (!_(e,
|
|
3528
|
-
let t =
|
|
3595
|
+
return { async resolveHost(e, t) {
|
|
3596
|
+
let n = await h(m(e)), r = Date.now();
|
|
3597
|
+
if (n && typeof n.freshUntilMs == "number") {
|
|
3598
|
+
if (n.freshUntilMs > r) return n.value;
|
|
3599
|
+
if (n.staleUntilMs > r) {
|
|
3600
|
+
if (!_(e, r)) {
|
|
3601
|
+
let t = y(e).catch(() => void 0);
|
|
3529
3602
|
c && c(t);
|
|
3530
3603
|
}
|
|
3531
|
-
return
|
|
3604
|
+
return n.value;
|
|
3532
3605
|
}
|
|
3533
3606
|
}
|
|
3534
3607
|
try {
|
|
3535
|
-
return await
|
|
3608
|
+
return await y(e, t?.signal);
|
|
3536
3609
|
} catch (e) {
|
|
3537
|
-
if (
|
|
3610
|
+
if (n && (n.staleIfErrorUntilMs ?? n.staleUntilMs) > r) return n.value;
|
|
3538
3611
|
throw e;
|
|
3539
3612
|
}
|
|
3540
3613
|
} };
|
|
3541
3614
|
}
|
|
3542
|
-
function
|
|
3615
|
+
function Ai(e, t) {
|
|
3543
3616
|
return `${e}:${t.toLowerCase()}`;
|
|
3544
3617
|
}
|
|
3545
3618
|
//#endregion
|
|
3546
3619
|
//#region src/static/index.ts
|
|
3547
|
-
function
|
|
3620
|
+
function $() {
|
|
3548
3621
|
throw Error("Static proxy adapter is read-only; configure routes at init time");
|
|
3549
3622
|
}
|
|
3550
|
-
function
|
|
3623
|
+
function ji(e, t, n, r, i, a) {
|
|
3551
3624
|
return {
|
|
3552
3625
|
id: e.id ?? `${n}:${t}`,
|
|
3553
3626
|
tenant_id: r,
|
|
@@ -3562,10 +3635,10 @@ function Ti(e, t, n, r, i, a) {
|
|
|
3562
3635
|
updated_at: e.updated_at ?? a
|
|
3563
3636
|
};
|
|
3564
3637
|
}
|
|
3565
|
-
function
|
|
3638
|
+
function Mi(e) {
|
|
3566
3639
|
let t = (/* @__PURE__ */ new Date()).toISOString(), n = e.defaultTenantId ?? "static", r = /* @__PURE__ */ new Map();
|
|
3567
3640
|
for (let [i, a] of Object.entries(e.hosts)) {
|
|
3568
|
-
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) =>
|
|
3641
|
+
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) => ji(n, r, e, s, c, t)).sort((e, t) => e.priority - t.priority);
|
|
3569
3642
|
r.set(e, {
|
|
3570
3643
|
tenant_id: s,
|
|
3571
3644
|
custom_domain_id: c,
|
|
@@ -3576,13 +3649,13 @@ function Ei(e) {
|
|
|
3576
3649
|
return {
|
|
3577
3650
|
proxyRoutes: {
|
|
3578
3651
|
async create() {
|
|
3579
|
-
return
|
|
3652
|
+
return $();
|
|
3580
3653
|
},
|
|
3581
3654
|
async update() {
|
|
3582
|
-
return
|
|
3655
|
+
return $();
|
|
3583
3656
|
},
|
|
3584
3657
|
async remove() {
|
|
3585
|
-
return
|
|
3658
|
+
return $();
|
|
3586
3659
|
},
|
|
3587
3660
|
async get(e, t) {
|
|
3588
3661
|
for (let n of r.values()) {
|
|
@@ -3609,7 +3682,7 @@ function Ei(e) {
|
|
|
3609
3682
|
}
|
|
3610
3683
|
};
|
|
3611
3684
|
}
|
|
3612
|
-
function
|
|
3685
|
+
function Ni(e, t = {}) {
|
|
3613
3686
|
return {
|
|
3614
3687
|
priority: t.priority,
|
|
3615
3688
|
match: { path: t.path ?? "/*" },
|
|
@@ -3624,10 +3697,10 @@ function Di(e, t = {}) {
|
|
|
3624
3697
|
}
|
|
3625
3698
|
//#endregion
|
|
3626
3699
|
//#region src/constants.ts
|
|
3627
|
-
var
|
|
3700
|
+
var Pi = "proxy:resolve_host";
|
|
3628
3701
|
//#endregion
|
|
3629
3702
|
//#region src/http-adapter/index.ts
|
|
3630
|
-
function
|
|
3703
|
+
function Fi() {
|
|
3631
3704
|
let e = () => {
|
|
3632
3705
|
throw Error("HTTP proxy adapter does not expose write access to proxy_routes; mutate via the control-plane management API");
|
|
3633
3706
|
};
|
|
@@ -3649,19 +3722,19 @@ function ki() {
|
|
|
3649
3722
|
}
|
|
3650
3723
|
};
|
|
3651
3724
|
}
|
|
3652
|
-
function
|
|
3725
|
+
function Ii(e) {
|
|
3653
3726
|
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;
|
|
3654
|
-
function c(e) {
|
|
3655
|
-
let
|
|
3656
|
-
|
|
3657
|
-
|
|
3727
|
+
function c(e, t) {
|
|
3728
|
+
let n = new AbortController(), r = er([e, n.signal]) ?? n.signal, i, a = new Promise((e, t) => {
|
|
3729
|
+
i = setTimeout(() => {
|
|
3730
|
+
n.abort(), t(new B(s, "control plane"));
|
|
3658
3731
|
}, s);
|
|
3659
3732
|
});
|
|
3660
|
-
return Promise.race([
|
|
3733
|
+
return Promise.race([t(r), a]).finally(() => clearTimeout(i));
|
|
3661
3734
|
}
|
|
3662
3735
|
let l = null;
|
|
3663
|
-
async function u() {
|
|
3664
|
-
let
|
|
3736
|
+
async function u(r) {
|
|
3737
|
+
let s = await c(r, async (r) => {
|
|
3665
3738
|
let o = await t(`${n}/oauth/token`, {
|
|
3666
3739
|
method: "POST",
|
|
3667
3740
|
headers: { "content-type": "application/json" },
|
|
@@ -3676,22 +3749,22 @@ function Ai(e) {
|
|
|
3676
3749
|
});
|
|
3677
3750
|
if (!o.ok) throw Error(`Proxy adapter token request failed: ${o.status} ${await o.text().catch(() => "")}`);
|
|
3678
3751
|
return await o.json();
|
|
3679
|
-
}),
|
|
3752
|
+
}), u = s.expires_in ?? 3600;
|
|
3680
3753
|
return l = {
|
|
3681
|
-
value:
|
|
3682
|
-
expires_at: Date.now() + (
|
|
3683
|
-
},
|
|
3754
|
+
value: s.access_token,
|
|
3755
|
+
expires_at: Date.now() + (u - o) * 1e3
|
|
3756
|
+
}, s.access_token;
|
|
3684
3757
|
}
|
|
3685
|
-
async function d() {
|
|
3686
|
-
return l && l.expires_at > Date.now() ? l.value : u();
|
|
3758
|
+
async function d(e) {
|
|
3759
|
+
return l && l.expires_at > Date.now() ? l.value : u(e);
|
|
3687
3760
|
}
|
|
3688
3761
|
return {
|
|
3689
|
-
proxyRoutes:
|
|
3690
|
-
async resolveHost(e) {
|
|
3691
|
-
let i = await d(),
|
|
3692
|
-
return c(async (e) => {
|
|
3693
|
-
let n = await t(
|
|
3694
|
-
headers: { authorization: `Bearer ${
|
|
3762
|
+
proxyRoutes: Fi(),
|
|
3763
|
+
async resolveHost(e, i) {
|
|
3764
|
+
let a = i?.signal, o = await d(a), s = `${n}${r}${encodeURIComponent(e.toLowerCase())}`;
|
|
3765
|
+
return c(a, async (e) => {
|
|
3766
|
+
let n = await t(s, {
|
|
3767
|
+
headers: { authorization: `Bearer ${o}` },
|
|
3695
3768
|
signal: e
|
|
3696
3769
|
});
|
|
3697
3770
|
if (n.status === 404) return null;
|
|
@@ -3703,7 +3776,7 @@ function Ai(e) {
|
|
|
3703
3776
|
}
|
|
3704
3777
|
//#endregion
|
|
3705
3778
|
//#region src/http-adapter/service-binding-fetch.ts
|
|
3706
|
-
function
|
|
3779
|
+
function Li(e) {
|
|
3707
3780
|
return (t, n) => {
|
|
3708
3781
|
let r = t instanceof Request && n === void 0 ? t : new Request(t, n);
|
|
3709
3782
|
return e.fetch(r);
|
|
@@ -3711,11 +3784,11 @@ function ji(e) {
|
|
|
3711
3784
|
}
|
|
3712
3785
|
//#endregion
|
|
3713
3786
|
//#region src/kv-adapter/index.ts
|
|
3714
|
-
var
|
|
3715
|
-
function
|
|
3787
|
+
var Ri = "authhero-proxy-host:";
|
|
3788
|
+
function zi(e, t) {
|
|
3716
3789
|
return `${e}${t.toLowerCase()}`;
|
|
3717
3790
|
}
|
|
3718
|
-
function
|
|
3791
|
+
function Bi() {
|
|
3719
3792
|
let e = () => {
|
|
3720
3793
|
throw Error("KV proxy adapter does not expose write access to proxy_routes; mutate via the control-plane management API");
|
|
3721
3794
|
};
|
|
@@ -3737,15 +3810,15 @@ function Ni() {
|
|
|
3737
3810
|
}
|
|
3738
3811
|
};
|
|
3739
3812
|
}
|
|
3740
|
-
function
|
|
3741
|
-
let { kv: t, keyPrefix: n =
|
|
3813
|
+
function Vi(e) {
|
|
3814
|
+
let { kv: t, keyPrefix: n = Ri, timeoutMs: r } = e;
|
|
3742
3815
|
return {
|
|
3743
|
-
proxyRoutes:
|
|
3816
|
+
proxyRoutes: Bi(),
|
|
3744
3817
|
async resolveHost(e) {
|
|
3745
|
-
let i =
|
|
3746
|
-
return (r && r > 0 ? await
|
|
3818
|
+
let i = zi(n, e), a = t.get(i, "json");
|
|
3819
|
+
return (r && r > 0 ? await W(a, r, "kv.get") : await a) ?? null;
|
|
3747
3820
|
}
|
|
3748
3821
|
};
|
|
3749
3822
|
}
|
|
3750
3823
|
//#endregion
|
|
3751
|
-
export {
|
|
3824
|
+
export { Ri as DEFAULT_KV_HOST_KEY_PREFIX, fi as FORWARDED_HEADERS_HANDLER_TYPE, rr as HandlerRegistry, Pi as PROXY_RESOLVE_HOST_SCOPE, br as basicAuthHandler, Ai as buildCacheAdapterKey, Ti as buildCacheApiKey, zi as buildKvHostKey, di as buildMatchFilter, Sr as cacheHandler, Z as compileHostApp, _r as corsHandler, ki as createCacheAdapterHostCache, wi as createCacheApiHostCache, Ii as createHttpProxyAdapter, G as createInMemoryHostCache, Vi as createKvProxyAdapter, yi as createProxyApp, Q as createProxyDataPlaneHandler, vi as createProxyDataPlaneRouter, Li as createServiceBindingFetch, Mi as createStaticProxyAdapter, K as defineHandler, ii as dispatchNamespaceHandler, Mr as forwardedHeadersHandler, wn as handlerConfigSchema, xr as headersHandler, Yr as httpHandler, Ni as httpRoute, jr as isCloudflareIp, Cn as matchSchema, ui as matchesAnyHost, li as matchesHost, z as proxyRouteInsertSchema, Tn as proxyRouteSchema, En as proxyRouteUpdateSchema, ai as redirectHandler, si as registerBuiltinHandlers, Ir as rewriteCookiesHandler, Lr as rewriteLocationHandler, $r as serviceBindingHandler, ci as sortRoutes, oi as staticHandler, pi as withForwardedHeaders, X as withForwardedHeadersFor };
|