authhero 4.105.0 → 4.106.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/authhero.mjs CHANGED
@@ -3300,10 +3300,6 @@ const LI = a.nativeEnum(ke), MI = a.object({
3300
3300
  // access tokens and a per-tenant grant-type allowlist.
3301
3301
  dcr_require_initial_access_token: a.boolean().optional(),
3302
3302
  dcr_allowed_grant_types: a.array(a.string()).optional(),
3303
- // Allowlist of `integration_type` values accepted by the
3304
- // `/connect/start` consent-mediated IAT flow. Empty/undefined disables
3305
- // the flow.
3306
- dcr_allowed_integration_types: a.array(a.string()).optional(),
3307
3303
  // Per-tenant allowlist of fully-qualified http origins (scheme + host
3308
3304
  // + port, no path) that may be used as `return_to` / `domain` on
3309
3305
  // `/connect/start` despite not being loopback. Off by default.
@@ -8278,7 +8274,7 @@ const W8 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
8278
8274
  logoDataUri: K8,
8279
8275
  validateAuthorizationCodeAndGetUser: G8
8280
8276
  }, Symbol.toStringTag, { value: "Module" }));
8281
- class V extends P {
8277
+ class G extends P {
8282
8278
  constructor(t, n) {
8283
8279
  super(t, {
8284
8280
  message: JSON.stringify(n),
@@ -8343,7 +8339,7 @@ async function Z8(e, t, n) {
8343
8339
  }
8344
8340
  );
8345
8341
  if (!l.ok)
8346
- throw new V(400, {
8342
+ throw new G(400, {
8347
8343
  message: "Failed to get user from vipps"
8348
8344
  });
8349
8345
  return await l.json();
@@ -9812,7 +9808,7 @@ function RN() {
9812
9808
  throw new TypeError();
9813
9809
  if (!fe(re) && !K(re) && !Ce(re))
9814
9810
  throw new TypeError();
9815
- return Ce(re) && (re = void 0), W = G(W), B(z, q, W, re);
9811
+ return Ce(re) && (re = void 0), W = V(W), B(z, q, W, re);
9816
9812
  }
9817
9813
  }
9818
9814
  n("decorate", v);
@@ -9830,51 +9826,51 @@ function RN() {
9830
9826
  function b(z, q, W, re) {
9831
9827
  if (!fe(W))
9832
9828
  throw new TypeError();
9833
- return K(re) || (re = G(re)), ie(z, q, W, re);
9829
+ return K(re) || (re = V(re)), ie(z, q, W, re);
9834
9830
  }
9835
9831
  n("defineMetadata", b);
9836
9832
  function S(z, q, W) {
9837
9833
  if (!fe(q))
9838
9834
  throw new TypeError();
9839
- return K(W) || (W = G(W)), M(z, q, W);
9835
+ return K(W) || (W = V(W)), M(z, q, W);
9840
9836
  }
9841
9837
  n("hasMetadata", S);
9842
9838
  function E(z, q, W) {
9843
9839
  if (!fe(q))
9844
9840
  throw new TypeError();
9845
- return K(W) || (W = G(W)), H(z, q, W);
9841
+ return K(W) || (W = V(W)), H(z, q, W);
9846
9842
  }
9847
9843
  n("hasOwnMetadata", E);
9848
9844
  function $(z, q, W) {
9849
9845
  if (!fe(q))
9850
9846
  throw new TypeError();
9851
- return K(W) || (W = G(W)), Y(z, q, W);
9847
+ return K(W) || (W = V(W)), Y(z, q, W);
9852
9848
  }
9853
9849
  n("getMetadata", $);
9854
9850
  function T(z, q, W) {
9855
9851
  if (!fe(q))
9856
9852
  throw new TypeError();
9857
- return K(W) || (W = G(W)), ne(z, q, W);
9853
+ return K(W) || (W = V(W)), ne(z, q, W);
9858
9854
  }
9859
9855
  n("getOwnMetadata", T);
9860
9856
  function O(z, q) {
9861
9857
  if (!fe(z))
9862
9858
  throw new TypeError();
9863
- return K(q) || (q = G(q)), Ae(z, q);
9859
+ return K(q) || (q = V(q)), Ae(z, q);
9864
9860
  }
9865
9861
  n("getMetadataKeys", O);
9866
9862
  function I(z, q) {
9867
9863
  if (!fe(z))
9868
9864
  throw new TypeError();
9869
- return K(q) || (q = G(q)), ve(z, q);
9865
+ return K(q) || (q = V(q)), ve(z, q);
9870
9866
  }
9871
9867
  n("getOwnMetadataKeys", I);
9872
9868
  function N(z, q, W) {
9873
9869
  if (!fe(q))
9874
9870
  throw new TypeError();
9875
- if (K(W) || (W = G(W)), !fe(q))
9871
+ if (K(W) || (W = V(W)), !fe(q))
9876
9872
  throw new TypeError();
9877
- K(W) || (W = G(W));
9873
+ K(W) || (W = V(W));
9878
9874
  var re = $r(
9879
9875
  q,
9880
9876
  W,
@@ -10057,7 +10053,7 @@ function RN() {
10057
10053
  function hn(z) {
10058
10054
  return "" + z;
10059
10055
  }
10060
- function G(z) {
10056
+ function V(z) {
10061
10057
  var q = Be(z);
10062
10058
  return _e(q) ? q : hn(q);
10063
10059
  }
@@ -21656,7 +21652,7 @@ async function j0(e, t) {
21656
21652
  try {
21657
21653
  const { header: n } = nO(t), r = (await rO(e.env)).find((c) => c.kid === n.kid);
21658
21654
  if (!r)
21659
- throw new V(401, { message: "No matching kid found" });
21655
+ throw new G(401, { message: "No matching kid found" });
21660
21656
  const o = await crypto.subtle.importKey(
21661
21657
  "jwk",
21662
21658
  r,
@@ -21666,7 +21662,7 @@ async function j0(e, t) {
21666
21662
  );
21667
21663
  return await tO(t, o, "RS256");
21668
21664
  } catch (n) {
21669
- throw n instanceof P ? n : new V(403, { message: "Invalid JWT signature" });
21665
+ throw n instanceof P ? n : new G(403, { message: "Invalid JWT signature" });
21670
21666
  }
21671
21667
  }
21672
21668
  function S_(e) {
@@ -21695,7 +21691,7 @@ function x_(e) {
21695
21691
  return await n();
21696
21692
  const d = S_(t.req.header("authorization"));
21697
21693
  if (!d)
21698
- throw new V(401, {
21694
+ throw new G(401, {
21699
21695
  message: "Missing bearer token"
21700
21696
  });
21701
21697
  try {
@@ -21706,9 +21702,9 @@ function x_(e) {
21706
21702
  (l.some(
21707
21703
  (h) => p.includes(h)
21708
21704
  ) || l.some((h) => f.includes(h))))
21709
- throw new V(403, { message: "Unauthorized" });
21705
+ throw new G(403, { message: "Unauthorized" });
21710
21706
  } catch (u) {
21711
- throw u instanceof P ? u : new V(403, { message: "Invalid token" });
21707
+ throw u instanceof P ? u : new G(403, { message: "Invalid token" });
21712
21708
  }
21713
21709
  }
21714
21710
  return await n();
@@ -22272,7 +22268,7 @@ async function it(e, t, n) {
22272
22268
  if (!r) {
22273
22269
  const f = await e.data.clients.getByClientId(t);
22274
22270
  if (!f)
22275
- throw new V(403, { message: "Client not found" });
22271
+ throw new G(403, { message: "Client not found" });
22276
22272
  const { tenant_id: h, ...g } = f;
22277
22273
  i = g, r = h;
22278
22274
  }
@@ -22283,11 +22279,11 @@ async function it(e, t, n) {
22283
22279
  e.data.connections.list(r)
22284
22280
  ]), d = i || o;
22285
22281
  if (!d)
22286
- throw new V(403, { message: "Client not found" });
22282
+ throw new G(403, { message: "Client not found" });
22287
22283
  if (d.client_metadata?.status === "deleted")
22288
- throw new V(403, { message: "Client not found" });
22284
+ throw new G(403, { message: "Client not found" });
22289
22285
  if (!s)
22290
- throw new V(404, { message: "Tenant not found" });
22286
+ throw new G(404, { message: "Tenant not found" });
22291
22287
  const u = c.length > 0 ? c : l.connections || [], p = Ft(e);
22292
22288
  return {
22293
22289
  ...d,
@@ -23661,27 +23657,27 @@ function FO(e, t, n) {
23661
23657
  }
23662
23658
  async function zO(e, t, n, i, r) {
23663
23659
  if (!n.redirect_uri)
23664
- throw new V(400, {
23660
+ throw new G(400, {
23665
23661
  message: "Missing redirect_uri in authParams"
23666
23662
  });
23667
23663
  if (!i.email)
23668
- throw new V(400, {
23664
+ throw new G(400, {
23669
23665
  message: "Missing email in user"
23670
23666
  });
23671
23667
  const { signingKeys: o } = await e.env.data.keys.list({
23672
23668
  q: "type:saml_encryption"
23673
23669
  }), [s] = o;
23674
23670
  if (!s)
23675
- throw new V(500, {
23671
+ throw new G(500, {
23676
23672
  message: "No signing key found"
23677
23673
  });
23678
23674
  if (!t.addons?.samlp)
23679
- throw new V(400, {
23675
+ throw new G(400, {
23680
23676
  message: `SAML Addon is not enabled for client ${t.client_id}`
23681
23677
  });
23682
23678
  const { recipient: c, audience: l } = t.addons.samlp, d = n.state || "";
23683
23679
  if (!c || !d || !i || !n.state)
23684
- throw new V(400, {
23680
+ throw new G(400, {
23685
23681
  message: "Missing recipient or inResponseTo"
23686
23682
  });
23687
23683
  const u = JSON.parse(n.state), p = new URL(n.redirect_uri), f = e.env.samlSigner || (e.env.SAML_SIGN_URL ? new UO(e.env.SAML_SIGN_URL) : void 0), h = await MO(
@@ -24147,7 +24143,7 @@ async function XO(e, t) {
24147
24143
  (E) => !m.includes(E)
24148
24144
  );
24149
24145
  if (S.length > 0)
24150
- throw new V(403, {
24146
+ throw new G(403, {
24151
24147
  error: "access_denied",
24152
24148
  error_description: `Client is not authorized for scope(s): ${S.join(", ")}`
24153
24149
  });
@@ -24217,7 +24213,7 @@ async function Hc(e, t) {
24217
24213
  })).userOrganizations.some(
24218
24214
  (M) => M.organization_id === s
24219
24215
  ))
24220
- throw new V(403, {
24216
+ throw new G(403, {
24221
24217
  error: "access_denied",
24222
24218
  error_description: "User is not a member of the specified organization"
24223
24219
  });
@@ -26874,7 +26870,7 @@ function dh(e, t, n) {
26874
26870
  },
26875
26871
  access: {
26876
26872
  deny: (i) => {
26877
- throw new V(400, {
26873
+ throw new G(400, {
26878
26874
  message: `Access denied: ${i}`
26879
26875
  });
26880
26876
  }
@@ -26907,10 +26903,10 @@ async function ff(e, t) {
26907
26903
  (j) => !j.revoked_at || new Date(j.revoked_at) > /* @__PURE__ */ new Date()
26908
26904
  );
26909
26905
  if (!p?.pkcs7)
26910
- throw new V(500, { message: "No signing key available" });
26906
+ throw new G(500, { message: "No signing key available" });
26911
26907
  const f = sE(p.pkcs7), h = Vi(e.env, e.var.custom_domain), g = n.audience ?? r.tenant.default_audience;
26912
26908
  if (!g)
26913
- throw new V(400, {
26909
+ throw new G(400, {
26914
26910
  error: "invalid_request",
26915
26911
  error_description: "An audience must be specified in the request or configured as the tenant default_audience"
26916
26912
  });
@@ -27124,7 +27120,7 @@ function Vu(e) {
27124
27120
  async function qE(e, t) {
27125
27121
  const { client: n, scope: i, login_id: r } = t, o = t.audience ?? n.tenant.default_audience;
27126
27122
  if (!o)
27127
- throw new V(400, {
27123
+ throw new G(400, {
27128
27124
  error: "invalid_request",
27129
27125
  error_description: "An audience must be specified in the request or configured as the tenant default_audience"
27130
27126
  });
@@ -27194,12 +27190,12 @@ async function HE(e, {
27194
27190
  });
27195
27191
  const c = s.state || ke.PENDING;
27196
27192
  if (c === ke.FAILED)
27197
- throw new V(400, {
27193
+ throw new G(400, {
27198
27194
  error: "access_denied",
27199
27195
  error_description: s.failure_reason || "Cannot authenticate login session in failed state"
27200
27196
  });
27201
27197
  if (c === ke.COMPLETED)
27202
- throw new V(400, {
27198
+ throw new G(400, {
27203
27199
  error: "access_denied",
27204
27200
  error_description: "Login session has already been completed"
27205
27201
  });
@@ -27444,7 +27440,7 @@ async function Ze(e, t) {
27444
27440
  const s = n.response_type || Pt.CODE, c = n.response_mode || Bn.QUERY;
27445
27441
  if (r) {
27446
27442
  if (!t.loginSession)
27447
- throw new V(500, {
27443
+ throw new G(500, {
27448
27444
  message: "Login session not found for ticket auth."
27449
27445
  });
27450
27446
  o && !t.skipHooks && (t.authStrategy && o.app_metadata?.strategy !== t.authStrategy.strategy && (o.app_metadata = {
@@ -27491,17 +27487,17 @@ async function Ze(e, t) {
27491
27487
  t.loginSession.id
27492
27488
  );
27493
27489
  if (!h)
27494
- throw new V(500, {
27490
+ throw new G(500, {
27495
27491
  message: "Login session not found."
27496
27492
  });
27497
27493
  const g = h.state || ke.PENDING;
27498
27494
  if (g === ke.COMPLETED)
27499
- throw new V(400, {
27495
+ throw new G(400, {
27500
27496
  error: "invalid_request",
27501
27497
  error_description: "Login session has already been completed"
27502
27498
  });
27503
27499
  if (g === ke.FAILED)
27504
- throw new V(400, {
27500
+ throw new G(400, {
27505
27501
  error: "access_denied",
27506
27502
  error_description: `Login session failed: ${h.failure_reason || "unknown reason"}`
27507
27503
  });
@@ -27514,11 +27510,11 @@ async function Ze(e, t) {
27514
27510
  authConnection: t.authConnection
27515
27511
  });
27516
27512
  else if (d = h.session_id, !d)
27517
- throw new V(500, {
27513
+ throw new G(500, {
27518
27514
  message: `Login session in ${g} state but has no session_id`
27519
27515
  });
27520
27516
  } else
27521
- throw new V(500, {
27517
+ throw new G(500, {
27522
27518
  message: "loginSession must be provided for front-channel auth responses."
27523
27519
  });
27524
27520
  if (t.loginSession && o) {
@@ -27737,7 +27733,7 @@ async function Ze(e, t) {
27737
27733
  return u;
27738
27734
  if (c === Bn.WEB_MESSAGE) {
27739
27735
  if (!n.redirect_uri)
27740
- throw new V(400, {
27736
+ throw new G(400, {
27741
27737
  message: "Redirect URI not allowed for WEB_MESSAGE response mode."
27742
27738
  });
27743
27739
  const h = new Headers();
@@ -27759,7 +27755,7 @@ async function Ze(e, t) {
27759
27755
  );
27760
27756
  }
27761
27757
  if (!n.redirect_uri)
27762
- throw new V(400, {
27758
+ throw new G(400, {
27763
27759
  message: "Redirect uri not found for this response mode."
27764
27760
  });
27765
27761
  const p = new Headers();
@@ -27783,7 +27779,7 @@ async function Ze(e, t) {
27783
27779
  ...n.scope && { scope: n.scope }
27784
27780
  }).toString();
27785
27781
  else
27786
- throw new V(500, {
27782
+ throw new G(500, {
27787
27783
  message: "Invalid token response for implicit flow."
27788
27784
  });
27789
27785
  return p.set("location", f.toString()), new Response("Redirecting", {
@@ -27804,7 +27800,7 @@ async function kR(e, t) {
27804
27800
  )).userOrganizations.some(
27805
27801
  (f) => f.organization_id === t.organization.id
27806
27802
  ))
27807
- throw new V(403, {
27803
+ throw new G(403, {
27808
27804
  error: "access_denied",
27809
27805
  error_description: "User is not a member of the specified organization"
27810
27806
  });
@@ -27825,7 +27821,7 @@ async function kR(e, t) {
27825
27821
  else {
27826
27822
  const p = n?.user_id || t.user?.user_id;
27827
27823
  if (!p)
27828
- throw new V(400, {
27824
+ throw new G(400, {
27829
27825
  error: "invalid_request",
27830
27826
  error_description: "User ID is required for user-based grants"
27831
27827
  });
@@ -27877,7 +27873,7 @@ async function kR(e, t) {
27877
27873
  const d = t.loginSession?.auth_connection || t.authConnection || e.var.connection;
27878
27874
  if (i === Pt.CODE) {
27879
27875
  if (!n || !t.loginSession)
27880
- throw new V(500, {
27876
+ throw new G(500, {
27881
27877
  message: "User and loginSession is required for code flow"
27882
27878
  });
27883
27879
  const u = await zE(e, {
@@ -28171,7 +28167,7 @@ function $R(e) {
28171
28167
  t,
28172
28168
  n.linked_to
28173
28169
  ))
28174
- throw new V(400, {
28170
+ throw new G(400, {
28175
28171
  error: "invalid_request",
28176
28172
  error_description: "Primary user does not exist"
28177
28173
  });
@@ -28182,7 +28178,7 @@ function $R(e) {
28182
28178
  n.linked_to
28183
28179
  );
28184
28180
  if (!c)
28185
- throw new V(500, {
28181
+ throw new G(500, {
28186
28182
  error: "server_error",
28187
28183
  error_description: "Failed to fetch primary user after linking"
28188
28184
  });
@@ -28213,7 +28209,7 @@ async function NR(e, t, n) {
28213
28209
  if (o.linked_to) {
28214
28210
  const s = await e.users.get(t, o.linked_to);
28215
28211
  if (!s)
28216
- throw new V(500, {
28212
+ throw new G(500, {
28217
28213
  error: "server_error",
28218
28214
  error_description: "Primary user does not exist for linked user"
28219
28215
  });
@@ -28327,7 +28323,7 @@ async function PR(e, t, n, i, r) {
28327
28323
  throw U(e, t.tenant.id, {
28328
28324
  type: L.FAILED_SIGNUP,
28329
28325
  description: o.reason || "Signup not allowed"
28330
- }), new V(400, {
28326
+ }), new G(400, {
28331
28327
  message: o.reason || "Signups are disabled for this client"
28332
28328
  });
28333
28329
  await ER(e)(t.tenant.id, i);
@@ -28367,7 +28363,7 @@ function jR(e, t) {
28367
28363
  },
28368
28364
  access: {
28369
28365
  deny: (l, d) => {
28370
- throw new V(400, {
28366
+ throw new G(400, {
28371
28367
  message: d ? `Registration denied: ${l} - ${d}` : `Registration denied: ${l}`
28372
28368
  });
28373
28369
  }
@@ -28409,7 +28405,7 @@ function jR(e, t) {
28409
28405
  },
28410
28406
  access: {
28411
28407
  deny: (p, f) => {
28412
- throw new V(400, {
28408
+ throw new G(400, {
28413
28409
  message: f ? `Registration denied: ${p} - ${f}` : `Registration denied: ${p}`
28414
28410
  });
28415
28411
  }
@@ -28427,7 +28423,7 @@ function jR(e, t) {
28427
28423
  }
28428
28424
  const o = await $R(t)(n, i);
28429
28425
  if (!o.created)
28430
- throw new V(409, { message: "User already exists" });
28426
+ throw new G(409, { message: "User already exists" });
28431
28427
  const s = o.user;
28432
28428
  return await (async () => {
28433
28429
  if (e.env.hooks?.onExecutePostUserRegistration)
@@ -28486,7 +28482,7 @@ function OR(e, t) {
28486
28482
  return t.users.update(n, i, r);
28487
28483
  const o = await t.users.get(n, i);
28488
28484
  if (!o)
28489
- throw new V(404, {
28485
+ throw new G(404, {
28490
28486
  message: "User not found"
28491
28487
  });
28492
28488
  const s = {
@@ -28513,7 +28509,7 @@ function OR(e, t) {
28513
28509
  }
28514
28510
  },
28515
28511
  cancel: () => {
28516
- throw new V(400, {
28512
+ throw new G(400, {
28517
28513
  message: "User update cancelled by pre-update hook"
28518
28514
  });
28519
28515
  },
@@ -28525,13 +28521,13 @@ function OR(e, t) {
28525
28521
  type: L.ACTIONS_EXECUTION_FAILED,
28526
28522
  description: `Pre user update hook failed: ${c instanceof Error ? c.message : "Unknown error"}`,
28527
28523
  userId: i
28528
- }), new V(400, {
28524
+ }), new G(400, {
28529
28525
  message: "Pre user update hook failed"
28530
28526
  });
28531
28527
  }
28532
28528
  return await t.transaction(async (c) => {
28533
28529
  if (!await c.users.update(n, i, r))
28534
- throw new V(404, {
28530
+ throw new G(404, {
28535
28531
  message: "User not found"
28536
28532
  });
28537
28533
  if (r.email || r.email_verified) {
@@ -28590,7 +28586,7 @@ function RR(e, t) {
28590
28586
  },
28591
28587
  {
28592
28588
  cancel: () => {
28593
- throw new V(400, {
28589
+ throw new G(400, {
28594
28590
  message: "User deletion cancelled by pre-deletion hook"
28595
28591
  });
28596
28592
  },
@@ -28601,7 +28597,7 @@ function RR(e, t) {
28601
28597
  throw c instanceof P ? c : (U(e, n, {
28602
28598
  type: L.FAILED_HOOK,
28603
28599
  description: `Pre user deletion hook failed: ${c instanceof Error ? c.message : String(c)}`
28604
- }), new V(400, {
28600
+ }), new G(400, {
28605
28601
  message: "Pre user deletion hook failed"
28606
28602
  }));
28607
28603
  }
@@ -28611,7 +28607,7 @@ function RR(e, t) {
28611
28607
  throw U(e, n, {
28612
28608
  type: L.FAILED_HOOK,
28613
28609
  description: `Pre user deletion webhook failed: ${c instanceof Error ? c.message : String(c)}`
28614
- }), new V(400, {
28610
+ }), new G(400, {
28615
28611
  message: "Pre user deletion webhook failed"
28616
28612
  });
28617
28613
  }
@@ -31128,7 +31124,7 @@ function fh(e, t) {
31128
31124
  async function hd(e) {
31129
31125
  const t = await e.env.data.tenants.get(e.var.tenant_id);
31130
31126
  if (!t)
31131
- throw new V(404, {
31127
+ throw new G(404, {
31132
31128
  error: "invalid_request",
31133
31129
  error_description: "Tenant not found"
31134
31130
  });
@@ -31136,14 +31132,14 @@ async function hd(e) {
31136
31132
  }
31137
31133
  function gd(e) {
31138
31134
  if (!e.flags?.enable_dynamic_client_registration)
31139
- throw new V(404, {
31135
+ throw new G(404, {
31140
31136
  error: "invalid_request",
31141
31137
  error_description: "Dynamic Client Registration is not enabled"
31142
31138
  });
31143
31139
  }
31144
31140
  function Ua(e) {
31145
31141
  if (!e.clientRegistrationTokens)
31146
- throw new V(500, {
31142
+ throw new G(500, {
31147
31143
  error: "server_error",
31148
31144
  error_description: "Dynamic Client Registration requires a clientRegistrationTokens adapter"
31149
31145
  });
@@ -31159,14 +31155,14 @@ async function cD(e, t) {
31159
31155
  "iat"
31160
31156
  );
31161
31157
  if (!r.ok || !r.token)
31162
- throw new V(401, {
31158
+ throw new G(401, {
31163
31159
  error: "invalid_token",
31164
31160
  error_description: `Initial access token ${r.failure ?? "invalid"}`
31165
31161
  });
31166
31162
  return r.token;
31167
31163
  }
31168
31164
  if (t.flags?.dcr_require_initial_access_token !== !1)
31169
- throw new V(401, {
31165
+ throw new G(401, {
31170
31166
  error: "invalid_token",
31171
31167
  error_description: "Initial access token required"
31172
31168
  });
@@ -31174,7 +31170,7 @@ async function cD(e, t) {
31174
31170
  async function hh(e, t) {
31175
31171
  const n = S_(e.req.header("authorization"));
31176
31172
  if (!n)
31177
- throw new V(401, {
31173
+ throw new G(401, {
31178
31174
  error: "invalid_token",
31179
31175
  error_description: "Registration access token required"
31180
31176
  });
@@ -31185,12 +31181,12 @@ async function hh(e, t) {
31185
31181
  "rat"
31186
31182
  );
31187
31183
  if (!i.ok || !i.token)
31188
- throw new V(401, {
31184
+ throw new G(401, {
31189
31185
  error: "invalid_token",
31190
31186
  error_description: `Registration access token ${i.failure ?? "invalid"}`
31191
31187
  });
31192
31188
  if (i.token.client_id !== t)
31193
- throw new V(401, {
31189
+ throw new G(401, {
31194
31190
  error: "invalid_token",
31195
31191
  error_description: "Registration access token is not bound to this client"
31196
31192
  });
@@ -33616,13 +33612,13 @@ function ln(e, t) {
33616
33612
  }
33617
33613
  async function A1(e, t, n, i) {
33618
33614
  if (!i.state)
33619
- throw new V(400, { message: "State not found" });
33615
+ throw new G(400, { message: "State not found" });
33620
33616
  const r = t.connections.find((l) => l.name === n);
33621
33617
  if (!r)
33622
33618
  throw e.set("client_id", t.client_id), await U(e, t.tenant.id, {
33623
33619
  type: L.FAILED_LOGIN,
33624
33620
  description: "Connection not found"
33625
- }), new V(403, { message: "Connection Not Found" });
33621
+ }), new G(403, { message: "Connection Not Found" });
33626
33622
  let o = await e.env.data.loginSessions.get(
33627
33623
  t.tenant.id,
33628
33624
  i.state
@@ -33664,13 +33660,13 @@ async function FD(e, { code: t, state: n }) {
33664
33660
  "oauth2_state"
33665
33661
  );
33666
33662
  if (!r || !r.connection_id)
33667
- throw new V(403, { message: "State not found" });
33663
+ throw new G(403, { message: "State not found" });
33668
33664
  const o = await i.data.loginSessions.get(
33669
33665
  e.var.tenant_id || "",
33670
33666
  r.login_id
33671
33667
  );
33672
33668
  if (!o)
33673
- throw new V(403, { message: "Session not found" });
33669
+ throw new G(403, { message: "Session not found" });
33674
33670
  const s = await it(
33675
33671
  i,
33676
33672
  o.authParams.client_id
@@ -33683,12 +33679,12 @@ async function FD(e, { code: t, state: n }) {
33683
33679
  throw await U(e, s.tenant.id, {
33684
33680
  type: L.FAILED_LOGIN,
33685
33681
  description: "Connection not found"
33686
- }), new V(403, { message: "Connection not found" });
33682
+ }), new G(403, { message: "Connection not found" });
33687
33683
  if (e.set("connection", c.name), !o.authParams.redirect_uri)
33688
33684
  throw await U(e, s.tenant.id, {
33689
33685
  type: L.FAILED_LOGIN,
33690
33686
  description: "Redirect URI not defined"
33691
- }), new V(403, { message: "Redirect URI not defined" });
33687
+ }), new G(403, { message: "Redirect URI not defined" });
33692
33688
  const d = await K3(e, c.strategy).validateAuthorizationCodeAndGetUser(
33693
33689
  e,
33694
33690
  c,
@@ -33809,7 +33805,7 @@ async function k1(e, t) {
33809
33805
  throw new P(500, { message: "Internal server error" });
33810
33806
  return c;
33811
33807
  } catch (c) {
33812
- if (c instanceof V) {
33808
+ if (c instanceof G) {
33813
33809
  if (c.status === 403)
33814
33810
  return V0(e, "state_not_found");
33815
33811
  if (c.status === 400) {
@@ -34206,7 +34202,7 @@ const GD = a.object({
34206
34202
  const c = e.req.header("authorization") || "", [l, d] = c.split(" ");
34207
34203
  if (l?.toLowerCase() === "bearer" && d) {
34208
34204
  if (t = await j0(e, d), !(t?.scope?.split(" ") || []).includes("openid"))
34209
- throw new V(403, {
34205
+ throw new G(403, {
34210
34206
  message: "openid scope required"
34211
34207
  });
34212
34208
  e.set("user", t);
@@ -34217,13 +34213,13 @@ const GD = a.object({
34217
34213
  const c = await e.req.parseBody(), l = typeof c.access_token == "string" ? c.access_token : void 0;
34218
34214
  if (l) {
34219
34215
  if (t = await j0(e, l), !(t?.scope?.split(" ") || []).includes("openid"))
34220
- throw new V(403, {
34216
+ throw new G(403, {
34221
34217
  message: "openid scope required"
34222
34218
  });
34223
34219
  e.set("user", t);
34224
34220
  }
34225
34221
  } catch (c) {
34226
- if (c instanceof P || c instanceof V)
34222
+ if (c instanceof P || c instanceof G)
34227
34223
  throw c;
34228
34224
  }
34229
34225
  if (!t)
@@ -34428,7 +34424,7 @@ async function QD(e, t) {
34428
34424
  throw U(e, n.tenant.id, {
34429
34425
  type: L.FAILED_EXCHANGE_ACCESS_TOKEN_FOR_CLIENT_CREDENTIALS,
34430
34426
  description: "Invalid client credentials"
34431
- }), new V(403, { message: "Invalid client credentials" });
34427
+ }), new G(403, { message: "Invalid client credentials" });
34432
34428
  let i;
34433
34429
  if (t.organization) {
34434
34430
  const o = await e.env.data.organizations.get(
@@ -34439,7 +34435,7 @@ async function QD(e, t) {
34439
34435
  throw U(e, n.tenant.id, {
34440
34436
  type: L.FAILED_EXCHANGE_ACCESS_TOKEN_FOR_CLIENT_CREDENTIALS,
34441
34437
  description: `Organization '${t.organization}' not found`
34442
- }), new V(400, {
34438
+ }), new G(400, {
34443
34439
  error: "invalid_request",
34444
34440
  error_description: `Organization '${t.organization}' not found`
34445
34441
  });
@@ -34485,19 +34481,19 @@ async function ZD(e, t) {
34485
34481
  throw U(e, n.tenant.id, {
34486
34482
  type: L.FAILED_EXCHANGE_AUTHORIZATION_CODE_FOR_ACCESS_TOKEN,
34487
34483
  description: "Invalid client credentials"
34488
- }), new V(403, { message: "Invalid client credentials" });
34484
+ }), new G(403, { message: "Invalid client credentials" });
34489
34485
  if (new Date(i.expires_at) < /* @__PURE__ */ new Date())
34490
34486
  throw U(e, n.tenant.id, {
34491
34487
  type: L.FAILED_EXCHANGE_AUTHORIZATION_CODE_FOR_ACCESS_TOKEN,
34492
34488
  description: "Code expired",
34493
34489
  userId: i.user_id
34494
- }), new V(403, { message: "Code expired" });
34490
+ }), new G(403, { message: "Code expired" });
34495
34491
  if (i.used_at)
34496
34492
  throw U(e, n.tenant.id, {
34497
34493
  type: L.FAILED_EXCHANGE_AUTHORIZATION_CODE_FOR_ACCESS_TOKEN,
34498
34494
  description: "Invalid authorization code",
34499
34495
  userId: i.user_id
34500
- }), new V(400, {
34496
+ }), new G(400, {
34501
34497
  error: "invalid_grant",
34502
34498
  error_description: "Invalid authorization code"
34503
34499
  });
@@ -34506,9 +34502,9 @@ async function ZD(e, t) {
34506
34502
  i.login_id
34507
34503
  );
34508
34504
  if (!r)
34509
- throw new V(403, { message: "Invalid login" });
34505
+ throw new G(403, { message: "Invalid login" });
34510
34506
  if (t.organization && r.authParams.organization && t.organization !== r.authParams.organization)
34511
- throw new V(400, {
34507
+ throw new G(400, {
34512
34508
  error: "invalid_request",
34513
34509
  error_description: "Organization parameter does not match login session organization"
34514
34510
  });
@@ -34523,7 +34519,7 @@ async function ZD(e, t) {
34523
34519
  type: L.FAILED_EXCHANGE_AUTHORIZATION_CODE_FOR_ACCESS_TOKEN,
34524
34520
  description: "Invalid client credentials",
34525
34521
  userId: i.user_id
34526
- }), new V(403, {
34522
+ }), new G(403, {
34527
34523
  message: "Invalid client credentials"
34528
34524
  });
34529
34525
  } else if (i.code_challenge && i.code_challenge_method && t.code_verifier) {
@@ -34536,7 +34532,7 @@ async function ZD(e, t) {
34536
34532
  type: L.FAILED_EXCHANGE_AUTHORIZATION_CODE_FOR_ACCESS_TOKEN,
34537
34533
  description: "Invalid client credentials",
34538
34534
  userId: i.user_id
34539
- }), new V(403, {
34535
+ }), new G(403, {
34540
34536
  message: "Invalid client credentials"
34541
34537
  });
34542
34538
  }
@@ -34545,13 +34541,13 @@ async function ZD(e, t) {
34545
34541
  type: L.FAILED_EXCHANGE_AUTHORIZATION_CODE_FOR_ACCESS_TOKEN,
34546
34542
  description: "Invalid redirect uri",
34547
34543
  userId: i.user_id
34548
- }), new V(403, { message: "Invalid redirect uri" });
34544
+ }), new G(403, { message: "Invalid redirect uri" });
34549
34545
  const o = await e.env.data.users.get(n.tenant.id, i.user_id);
34550
34546
  if (!o)
34551
- throw new V(403, { message: "User not found" });
34547
+ throw new G(403, { message: "User not found" });
34552
34548
  const s = o.linked_to ? await e.env.data.users.get(n.tenant.id, o.linked_to) : o;
34553
34549
  if (!s)
34554
- throw new V(403, { message: "User not found" });
34550
+ throw new G(403, { message: "User not found" });
34555
34551
  await e.env.data.codes.used(n.tenant.id, t.code);
34556
34552
  let c;
34557
34553
  r.session_id && r.authParams.scope?.split(" ").includes("offline_access") && (c = await qE(e, {
@@ -34635,7 +34631,7 @@ async function eB(e, t) {
34635
34631
  throw U(e, n.tenant.id, {
34636
34632
  type: L.FAILED_EXCHANGE_REFRESH_TOKEN_FOR_ACCESS_TOKEN,
34637
34633
  description: "Client authentication failed"
34638
- }), new V(403, {
34634
+ }), new G(403, {
34639
34635
  error: "invalid_client",
34640
34636
  error_description: "Client authentication failed"
34641
34637
  });
@@ -34649,7 +34645,7 @@ async function eB(e, t) {
34649
34645
  type: L.FAILED_EXCHANGE_REFRESH_TOKEN_FOR_ACCESS_TOKEN,
34650
34646
  description: "Refresh token has been revoked",
34651
34647
  userId: i.user_id
34652
- }), new V(400, {
34648
+ }), new G(400, {
34653
34649
  error: "invalid_grant",
34654
34650
  error_description: "Refresh token has been revoked"
34655
34651
  });
@@ -34658,14 +34654,14 @@ async function eB(e, t) {
34658
34654
  type: L.FAILED_EXCHANGE_REFRESH_TOKEN_FOR_ACCESS_TOKEN,
34659
34655
  description: "Refresh token has expired",
34660
34656
  userId: i.user_id
34661
- }), new V(400, {
34657
+ }), new G(400, {
34662
34658
  error: "invalid_grant",
34663
34659
  error_description: "Refresh token has expired"
34664
34660
  });
34665
34661
  } else throw vh(e, `Invalid refresh token: ${t.refresh_token}`), U(e, n.tenant.id, {
34666
34662
  type: L.FAILED_EXCHANGE_REFRESH_TOKEN_FOR_ACCESS_TOKEN,
34667
34663
  description: "Invalid refresh token"
34668
- }), new V(400, {
34664
+ }), new G(400, {
34669
34665
  error: "invalid_grant",
34670
34666
  error_description: "Invalid refresh token"
34671
34667
  });
@@ -34674,10 +34670,10 @@ async function eB(e, t) {
34674
34670
  i.user_id
34675
34671
  );
34676
34672
  if (!r)
34677
- throw new V(403, { message: "User not found" });
34673
+ throw new G(403, { message: "User not found" });
34678
34674
  const o = r.linked_to ? await e.env.data.users.get(n.tenant.id, r.linked_to) : r;
34679
34675
  if (!o)
34680
- throw new V(403, { message: "User not found" });
34676
+ throw new G(403, { message: "User not found" });
34681
34677
  e.set("user_id", o.user_id);
34682
34678
  const s = i.resource_servers[0];
34683
34679
  let c, l;
@@ -34695,7 +34691,7 @@ async function eB(e, t) {
34695
34691
  if (p)
34696
34692
  u = { id: p.id, name: p.name };
34697
34693
  else
34698
- throw new V(400, {
34694
+ throw new G(400, {
34699
34695
  error: "invalid_request",
34700
34696
  error_description: `Organization '${d}' not found`
34701
34697
  });
@@ -34737,7 +34733,7 @@ async function eB(e, t) {
34737
34733
  )).userOrganizations.some(
34738
34734
  (_) => _.organization_id === u.id
34739
34735
  ))
34740
- throw new V(403, {
34736
+ throw new G(403, {
34741
34737
  error: "access_denied",
34742
34738
  error_description: "User is not a member of the specified organization"
34743
34739
  });
@@ -36553,7 +36549,7 @@ async function hC(e, {
36553
36549
  c
36554
36550
  );
36555
36551
  if (!d)
36556
- throw new V(400, {
36552
+ throw new G(400, {
36557
36553
  message: "Invalid username format"
36558
36554
  });
36559
36555
  e.set("connection", l);
@@ -36562,7 +36558,7 @@ async function hC(e, {
36562
36558
  throw U(e, u.tenant.id, {
36563
36559
  type: L.FAILED_EXCHANGE_PASSWORD_OTP_FOR_ACCESS_TOKEN,
36564
36560
  description: "Code invalid"
36565
- }), new V(400, {
36561
+ }), new G(400, {
36566
36562
  message: ye("code_invalid"),
36567
36563
  userSafe: !0
36568
36564
  });
@@ -36571,7 +36567,7 @@ async function hC(e, {
36571
36567
  type: L.FAILED_EXCHANGE_PASSWORD_OTP_FOR_ACCESS_TOKEN,
36572
36568
  description: "Code expired",
36573
36569
  userId: f.user_id
36574
- }), new V(400, {
36570
+ }), new G(400, {
36575
36571
  message: ye("code_expired"),
36576
36572
  userSafe: !0
36577
36573
  });
@@ -36580,7 +36576,7 @@ async function hC(e, {
36580
36576
  type: L.FAILED_EXCHANGE_PASSWORD_OTP_FOR_ACCESS_TOKEN,
36581
36577
  description: "Code already used",
36582
36578
  userId: f.user_id
36583
- }), new V(400, {
36579
+ }), new G(400, {
36584
36580
  message: ye("code_used"),
36585
36581
  userSafe: !0
36586
36582
  });
@@ -36593,7 +36589,7 @@ async function hC(e, {
36593
36589
  type: L.FAILED_EXCHANGE_PASSWORD_OTP_FOR_ACCESS_TOKEN,
36594
36590
  description: "Login session not found or username mismatch",
36595
36591
  userId: f.user_id
36596
- }), new V(400, {
36592
+ }), new G(400, {
36597
36593
  message: "Code not found or expired",
36598
36594
  userSafe: !0
36599
36595
  });
@@ -36839,7 +36835,7 @@ const wM = new ae().openapi(
36839
36835
  });
36840
36836
  else {
36841
36837
  if (!o.user?.user_id)
36842
- throw new V(400, {
36838
+ throw new G(400, {
36843
36839
  error: "invalid_request",
36844
36840
  error_description: "User ID is required for user-based grants"
36845
36841
  });
@@ -37516,7 +37512,7 @@ function xM(e) {
37516
37512
  async function _C(e, t, n, i) {
37517
37513
  const { data: r } = e.env, { username: o } = n;
37518
37514
  if (e.set("username", o), !o)
37519
- throw new V(400, { message: "Username is required" });
37515
+ throw new G(400, { message: "Username is required" });
37520
37516
  const s = await kr({
37521
37517
  userAdapter: e.env.data.users,
37522
37518
  tenant_id: t.tenant.id,
@@ -37840,20 +37836,20 @@ function IM(e) {
37840
37836
  return Qe;
37841
37837
  if (e === Q.EMAIL)
37842
37838
  return Q.EMAIL;
37843
- throw new V(403, { message: "Invalid realm" });
37839
+ throw new G(403, { message: "Invalid realm" });
37844
37840
  }
37845
37841
  async function $M(e, t, n, i, r) {
37846
37842
  const { env: o } = e;
37847
37843
  e.set("connection", r);
37848
37844
  const s = await o.data.codes.get(t, n, "ticket");
37849
37845
  if (!s || s.used_at)
37850
- throw new V(403, { message: "Ticket not found" });
37846
+ throw new G(403, { message: "Ticket not found" });
37851
37847
  const c = await o.data.loginSessions.get(
37852
37848
  t,
37853
37849
  s.login_id
37854
37850
  );
37855
37851
  if (!c || !c.authParams.username)
37856
- throw new V(403, { message: "Session not found" });
37852
+ throw new G(403, { message: "Session not found" });
37857
37853
  const l = await it(
37858
37854
  o,
37859
37855
  c.authParams.client_id,
@@ -38095,7 +38091,7 @@ async function RM(e, t) {
38095
38091
  t
38096
38092
  );
38097
38093
  if (!n)
38098
- throw new V(403, { message: "State not found" });
38094
+ throw new G(403, { message: "State not found" });
38099
38095
  const i = n.authorization_url;
38100
38096
  if (i && i.length <= PM) {
38101
38097
  let c = null;
@@ -38126,27 +38122,27 @@ async function RM(e, t) {
38126
38122
  ln(e, r.tenant.id), e.set("client_id", r.client_id);
38127
38123
  const o = n.state || ke.PENDING;
38128
38124
  if (o === ke.PENDING)
38129
- throw new V(400, {
38125
+ throw new G(400, {
38130
38126
  error: "invalid_request",
38131
38127
  error_description: "Login session is not yet authenticated"
38132
38128
  });
38133
38129
  if (o === ke.COMPLETED)
38134
- throw new V(409, {
38130
+ throw new G(409, {
38135
38131
  error: "invalid_request",
38136
38132
  error_description: "Login session has already been completed"
38137
38133
  });
38138
38134
  if (o === ke.FAILED)
38139
- throw new V(400, {
38135
+ throw new G(400, {
38140
38136
  error: "access_denied",
38141
38137
  error_description: `Login session failed: ${n.failure_reason || "unknown reason"}`
38142
38138
  });
38143
38139
  if (o === ke.EXPIRED)
38144
- throw new V(400, {
38140
+ throw new G(400, {
38145
38141
  error: "invalid_request",
38146
38142
  error_description: "Login session has expired"
38147
38143
  });
38148
38144
  if (!n.user_id)
38149
- throw new V(500, {
38145
+ throw new G(500, {
38150
38146
  message: "Authenticated login session has no user_id"
38151
38147
  });
38152
38148
  const s = await e.env.data.users.get(
@@ -38154,7 +38150,7 @@ async function RM(e, t) {
38154
38150
  n.user_id
38155
38151
  );
38156
38152
  if (!s)
38157
- throw new V(500, {
38153
+ throw new G(500, {
38158
38154
  message: "Authenticated user not found"
38159
38155
  });
38160
38156
  return e.set("user_id", s.user_id), n.auth_connection && e.set("connection", n.auth_connection), Ze(e, {
@@ -38741,12 +38737,12 @@ function X1(e) {
38741
38737
  try {
38742
38738
  const n = new URL(t);
38743
38739
  if (!n.protocol || !n.host)
38744
- throw new V(400, {
38740
+ throw new G(400, {
38745
38741
  error: "invalid_redirect_uri",
38746
38742
  error_description: `Invalid redirect_uri: ${t}`
38747
38743
  });
38748
38744
  } catch {
38749
- throw new V(400, {
38745
+ throw new G(400, {
38750
38746
  error: "invalid_redirect_uri",
38751
38747
  error_description: `Invalid redirect_uri: ${t}`
38752
38748
  });
@@ -38756,7 +38752,7 @@ function e2(e, t) {
38756
38752
  if (!(!e || !t || t.length === 0)) {
38757
38753
  for (const n of e)
38758
38754
  if (!t.includes(n))
38759
- throw new V(400, {
38755
+ throw new G(400, {
38760
38756
  error: "invalid_client_metadata",
38761
38757
  error_description: `grant_type "${n}" is not allowed for this tenant`
38762
38758
  });
@@ -38790,7 +38786,7 @@ const qM = new ae().openapi(
38790
38786
  gd(t);
38791
38787
  const n = await cD(e, t), i = e.req.valid("json"), r = Y1(n?.constraints, i);
38792
38788
  if (!r.ok)
38793
- throw new V(400, {
38789
+ throw new G(400, {
38794
38790
  error: "invalid_client_metadata",
38795
38791
  error_description: `Field "${r.violation?.field}" conflicts with Initial Access Token constraint`
38796
38792
  });
@@ -38798,7 +38794,7 @@ const qM = new ae().openapi(
38798
38794
  r.filled
38799
38795
  );
38800
38796
  if (!o.success)
38801
- throw new V(400, {
38797
+ throw new G(400, {
38802
38798
  error: "invalid_client_metadata",
38803
38799
  error_description: "Merged request (with IAT constraints applied) is not valid RFC 7591 metadata"
38804
38800
  });
@@ -38806,7 +38802,7 @@ const qM = new ae().openapi(
38806
38802
  if (s.grant_types?.some(
38807
38803
  (y) => y === "authorization_code" || y === "implicit"
38808
38804
  ) && (!s.redirect_uris || s.redirect_uris.length === 0))
38809
- throw new V(400, {
38805
+ throw new G(400, {
38810
38806
  error: "invalid_redirect_uri",
38811
38807
  error_description: "redirect_uris is required for authorization_code and implicit grant types"
38812
38808
  });
@@ -38839,7 +38835,7 @@ const qM = new ae().openapi(
38839
38835
  n.id,
38840
38836
  (/* @__PURE__ */ new Date()).toISOString()
38841
38837
  ))
38842
- throw new V(401, {
38838
+ throw new G(401, {
38843
38839
  error: "invalid_token",
38844
38840
  error_description: "Initial access token already used"
38845
38841
  });
@@ -38854,7 +38850,7 @@ const qM = new ae().openapi(
38854
38850
  single_use: !1
38855
38851
  });
38856
38852
  }), !g)
38857
- throw new V(500, {
38853
+ throw new G(500, {
38858
38854
  error: "server_error",
38859
38855
  error_description: "Failed to create client"
38860
38856
  });
@@ -38896,7 +38892,7 @@ const qM = new ae().openapi(
38896
38892
  n
38897
38893
  );
38898
38894
  if (!i || gh(i))
38899
- throw new V(401, {
38895
+ throw new G(401, {
38900
38896
  error: "invalid_token",
38901
38897
  error_description: "Client not found"
38902
38898
  });
@@ -38936,13 +38932,13 @@ const qM = new ae().openapi(
38936
38932
  n
38937
38933
  );
38938
38934
  if (!i || gh(i))
38939
- throw new V(401, {
38935
+ throw new G(401, {
38940
38936
  error: "invalid_token",
38941
38937
  error_description: "Client not found"
38942
38938
  });
38943
38939
  const r = e.req.valid("json");
38944
38940
  if (r.client_id !== void 0 && r.client_id !== n)
38945
- throw new V(400, {
38941
+ throw new G(400, {
38946
38942
  error: "invalid_client_metadata",
38947
38943
  error_description: "client_id in body does not match URL"
38948
38944
  });
@@ -38950,7 +38946,7 @@ const qM = new ae().openapi(
38950
38946
  if (o) {
38951
38947
  const h = Y1(o, r);
38952
38948
  if (!h.ok)
38953
- throw new V(400, {
38949
+ throw new G(400, {
38954
38950
  error: "invalid_client_metadata",
38955
38951
  error_description: `Field "${h.violation?.field}" was bound at registration time and cannot be changed`
38956
38952
  });
@@ -38975,7 +38971,7 @@ const qM = new ae().openapi(
38975
38971
  n,
38976
38972
  d
38977
38973
  ))
38978
- throw new V(500, {
38974
+ throw new G(500, {
38979
38975
  error: "server_error",
38980
38976
  error_description: "Failed to update client"
38981
38977
  });
@@ -38984,7 +38980,7 @@ const qM = new ae().openapi(
38984
38980
  n
38985
38981
  );
38986
38982
  if (!p)
38987
- throw new V(500, {
38983
+ throw new G(500, {
38988
38984
  error: "server_error",
38989
38985
  error_description: "Failed to read back updated client"
38990
38986
  });
@@ -39022,7 +39018,7 @@ const qM = new ae().openapi(
39022
39018
  n
39023
39019
  );
39024
39020
  if (!i || gh(i))
39025
- throw new V(401, {
39021
+ throw new G(401, {
39026
39022
  error: "invalid_token",
39027
39023
  error_description: "Client not found"
39028
39024
  });
@@ -39085,8 +39081,8 @@ function t2(e, t = []) {
39085
39081
  };
39086
39082
  }
39087
39083
  const KM = 1800, VM = a.object({
39088
- integration_type: a.string().min(1).openapi({
39089
- description: "Caller-defined integration identifier; allowlisted per tenant"
39084
+ integration_type: a.string().min(1).optional().openapi({
39085
+ description: "Optional caller-defined integration label. Surfaced on the consent screen and stored on the resulting client's IAT constraints. No validation beyond non-empty string."
39090
39086
  }),
39091
39087
  domain: a.string().min(1).openapi({
39092
39088
  description: "The domain that will host the integration (origin must match return_to)"
@@ -39126,55 +39122,44 @@ const KM = 1800, VM = a.object({
39126
39122
  async (e) => {
39127
39123
  const t = e.var.tenant_id, n = await e.env.data.tenants.get(t);
39128
39124
  if (!n)
39129
- throw new V(404, {
39125
+ throw new G(404, {
39130
39126
  error: "invalid_request",
39131
39127
  error_description: "Tenant not found"
39132
39128
  });
39133
39129
  if (!n.flags?.enable_dynamic_client_registration)
39134
- throw new V(404, {
39130
+ throw new G(404, {
39135
39131
  error: "invalid_request",
39136
39132
  error_description: "Dynamic Client Registration is not enabled"
39137
39133
  });
39138
- const { integration_type: i, domain: r, return_to: o, state: s, scope: c } = e.req.valid("query"), l = n.flags?.dcr_allowed_integration_types;
39139
- if (!l || l.length === 0)
39140
- throw new V(404, {
39134
+ const { integration_type: i, domain: r, return_to: o, state: s, scope: c } = e.req.valid("query"), l = n.flags?.allow_http_return_to ?? [], d = /^https?:\/\//i.test(r) ? r : `https://${r}`, u = t2(d, l);
39135
+ if (!u.ok)
39136
+ throw new G(400, {
39141
39137
  error: "invalid_request",
39142
- error_description: "Connect flow is not enabled for this tenant"
39138
+ error_description: `domain: ${u.reason}`
39143
39139
  });
39144
- if (!l.includes(i))
39145
- throw new V(400, {
39146
- error: "invalid_request",
39147
- error_description: `integration_type "${i}" is not allowed`
39148
- });
39149
- const d = n.flags?.allow_http_return_to ?? [], u = /^https?:\/\//i.test(r) ? r : `https://${r}`, p = t2(u, d);
39140
+ const p = t2(o, l);
39150
39141
  if (!p.ok)
39151
- throw new V(400, {
39152
- error: "invalid_request",
39153
- error_description: `domain: ${p.reason}`
39154
- });
39155
- const f = t2(o, d);
39156
- if (!f.ok)
39157
- throw new V(400, {
39142
+ throw new G(400, {
39158
39143
  error: "invalid_request",
39159
- error_description: `return_to: ${f.reason}`
39144
+ error_description: `return_to: ${p.reason}`
39160
39145
  });
39161
- if (f.origin !== p.origin)
39162
- throw new V(400, {
39146
+ if (p.origin !== u.origin)
39147
+ throw new G(400, {
39163
39148
  error: "invalid_request",
39164
39149
  error_description: "return_to origin must match domain"
39165
39150
  });
39166
- const { clients: h } = await e.env.data.clients.list(t), g = h[0];
39167
- if (!g)
39168
- throw new V(400, {
39151
+ const { clients: f } = await e.env.data.clients.list(t), h = f[0];
39152
+ if (!h)
39153
+ throw new G(400, {
39169
39154
  error: "invalid_request",
39170
39155
  error_description: "No clients configured for this tenant"
39171
39156
  });
39172
- const m = new Date(
39157
+ const g = new Date(
39173
39158
  Date.now() + KM * 1e3
39174
- ).toISOString(), _ = await e.env.data.loginSessions.create(t, {
39175
- expires_at: m,
39159
+ ).toISOString(), m = await e.env.data.loginSessions.create(t, {
39160
+ expires_at: g,
39176
39161
  authParams: {
39177
- client_id: g.client_id,
39162
+ client_id: h.client_id,
39178
39163
  state: s
39179
39164
  },
39180
39165
  csrf_token: ze(),
@@ -39187,12 +39172,12 @@ const KM = 1800, VM = a.object({
39187
39172
  return_to: o,
39188
39173
  scope: c,
39189
39174
  caller_state: s,
39190
- is_local_dev: f.isLoopback || f.isAllowlisted
39175
+ is_local_dev: p.isLoopback || p.isAllowlisted
39191
39176
  }
39192
39177
  })
39193
39178
  });
39194
39179
  return e.redirect(
39195
- `/u2/connect/start?state=${encodeURIComponent(_.id)}`,
39180
+ `/u2/connect/start?state=${encodeURIComponent(m.id)}`,
39196
39181
  302
39197
39182
  );
39198
39183
  }
@@ -39859,7 +39844,7 @@ function c2(e, t = "light") {
39859
39844
  const n = ty(e, "#ffffff"), i = ty(e, "#000000"), r = 1.35;
39860
39845
  return t === "light" ? i > n * r ? "#000000" : "#ffffff" : i * r > n ? "#000000" : "#ffffff";
39861
39846
  }
39862
- const Ha = "mohcx5au", _U = (e, t) => {
39847
+ const Ha = "moiiv77w", _U = (e, t) => {
39863
39848
  const n = e?.colors?.primary_button || t?.colors?.primary || "#000000", i = e?.colors?.base_hover_color || yU(n, 0.2), r = e?.colors?.primary_button_label, o = r && ty(r, n) >= 4.5, s = o ? r : c2(n, "light"), c = o ? r : c2(n, "dark"), l = s !== c ? `
39864
39849
  @media (prefers-color-scheme: dark) {
39865
39850
  body { --text-on-primary: ${c}; }
@@ -48004,16 +47989,16 @@ function KF() {
48004
47989
  function fe() {
48005
47990
  return K;
48006
47991
  }
48007
- function Be(G) {
48008
- throw $.error("Unclosed " + G, K);
47992
+ function Be(V) {
47993
+ throw $.error("Unclosed " + V, K);
48009
47994
  }
48010
47995
  function nt() {
48011
47996
  return _e.length === 0 && K >= Pe;
48012
47997
  }
48013
- function Xe(G) {
47998
+ function Xe(V) {
48014
47999
  if (_e.length) return _e.pop();
48015
48000
  if (K >= Pe) return;
48016
- let oe = G ? G.ignoreUnclosed : !1;
48001
+ let oe = V ? V.ignoreUnclosed : !1;
48017
48002
  switch (N = O.charCodeAt(K), N) {
48018
48003
  case r:
48019
48004
  case o:
@@ -48094,8 +48079,8 @@ function KF() {
48094
48079
  }
48095
48080
  return K++, Y;
48096
48081
  }
48097
- function hn(G) {
48098
- _e.push(G);
48082
+ function hn(V) {
48083
+ _e.push(V);
48099
48084
  }
48100
48085
  return {
48101
48086
  back: hn,
@@ -49030,9 +49015,9 @@ function QF() {
49030
49015
  return "";
49031
49016
  typeof _ == "number" && (_ = _.toString());
49032
49017
  let v = "", A = "";
49033
- function b(G, oe) {
49018
+ function b(V, oe) {
49034
49019
  const X = this;
49035
- this.tag = G, this.attribs = oe || {}, this.tagPosition = v.length, this.text = "", this.openingTagLength = 0, this.mediaChildren = [], this.updateParentNodeText = function() {
49020
+ this.tag = V, this.attribs = oe || {}, this.tagPosition = v.length, this.text = "", this.openingTagLength = 0, this.mediaChildren = [], this.updateParentNodeText = function() {
49036
49021
  if (H.length) {
49037
49022
  const Ee = H[H.length - 1];
49038
49023
  Ee.text += X.text;
@@ -49042,13 +49027,13 @@ function QF() {
49042
49027
  };
49043
49028
  }
49044
49029
  y = Object.assign({}, g.defaults, y), y.parser = Object.assign({}, m, y.parser);
49045
- const S = function(G) {
49046
- return y.allowedTags === !1 || (y.allowedTags || []).indexOf(G) > -1;
49030
+ const S = function(V) {
49031
+ return y.allowedTags === !1 || (y.allowedTags || []).indexOf(V) > -1;
49047
49032
  };
49048
- c.forEach(function(G) {
49049
- S(G) && !y.allowVulnerableTags && console.warn(`
49033
+ c.forEach(function(V) {
49034
+ S(V) && !y.allowVulnerableTags && console.warn(`
49050
49035
 
49051
- ⚠️ Your \`allowedTags\` option includes, \`${G}\`, which is inherently
49036
+ ⚠️ Your \`allowedTags\` option includes, \`${V}\`, which is inherently
49052
49037
  vulnerable to XSS attacks. Please remove it from \`allowedTags\`.
49053
49038
  Or, to disable this warning, add the \`allowVulnerableTags\` option
49054
49039
  and ensure you are accounting for this risk.
@@ -49062,54 +49047,54 @@ and ensure you are accounting for this risk.
49062
49047
  "option"
49063
49048
  ];
49064
49049
  let $, T;
49065
- y.allowedAttributes && ($ = {}, T = {}, l(y.allowedAttributes, function(G, oe) {
49050
+ y.allowedAttributes && ($ = {}, T = {}, l(y.allowedAttributes, function(V, oe) {
49066
49051
  $[oe] = [];
49067
49052
  const X = [];
49068
- G.forEach(function(Ee) {
49053
+ V.forEach(function(Ee) {
49069
49054
  typeof Ee == "string" && Ee.indexOf("*") >= 0 ? X.push(t(Ee).replace(/\\\*/g, ".*")) : $[oe].push(Ee);
49070
49055
  }), X.length && (T[oe] = new RegExp("^(" + X.join("|") + ")$"));
49071
49056
  }));
49072
49057
  const O = {}, I = {}, N = {};
49073
- l(y.allowedClasses, function(G, oe) {
49074
- if ($ && (d($, oe) || ($[oe] = []), $[oe].push("class")), O[oe] = G, Array.isArray(G)) {
49058
+ l(y.allowedClasses, function(V, oe) {
49059
+ if ($ && (d($, oe) || ($[oe] = []), $[oe].push("class")), O[oe] = V, Array.isArray(V)) {
49075
49060
  const X = [];
49076
- O[oe] = [], N[oe] = [], G.forEach(function(Ee) {
49061
+ O[oe] = [], N[oe] = [], V.forEach(function(Ee) {
49077
49062
  typeof Ee == "string" && Ee.indexOf("*") >= 0 ? X.push(t(Ee).replace(/\\\*/g, ".*")) : Ee instanceof RegExp ? N[oe].push(Ee) : O[oe].push(Ee);
49078
49063
  }), X.length && (I[oe] = new RegExp("^(" + X.join("|") + ")$"));
49079
49064
  }
49080
49065
  });
49081
49066
  const j = {};
49082
49067
  let B;
49083
- l(y.transformTags, function(G, oe) {
49068
+ l(y.transformTags, function(V, oe) {
49084
49069
  let X;
49085
- typeof G == "function" ? X = G : typeof G == "string" && (X = g.simpleTransform(G)), oe === "*" ? B = X : j[oe] = X;
49070
+ typeof V == "function" ? X = V : typeof V == "string" && (X = g.simpleTransform(V)), oe === "*" ? B = X : j[oe] = X;
49086
49071
  });
49087
49072
  let M, H, Y, ne, ie, Ae, ve = !1;
49088
49073
  K();
49089
49074
  const Pe = new e.Parser({
49090
- onopentag: function(G, oe) {
49091
- if (y.onOpenTag && y.onOpenTag(G, oe), y.enforceHtmlBoundary && G === "html" && K(), ie) {
49075
+ onopentag: function(V, oe) {
49076
+ if (y.onOpenTag && y.onOpenTag(V, oe), y.enforceHtmlBoundary && V === "html" && K(), ie) {
49092
49077
  Ae++;
49093
49078
  return;
49094
49079
  }
49095
- const X = new b(G, oe);
49080
+ const X = new b(V, oe);
49096
49081
  H.push(X);
49097
49082
  let Ee = !1;
49098
49083
  const gt = !!X.text;
49099
49084
  let mt;
49100
- if (d(j, G) && (mt = j[G](G, oe), X.attribs = oe = mt.attribs, mt.text !== void 0 && (X.innerText = mt.text), G !== mt.tagName && (X.name = G = mt.tagName, ne[M] = mt.tagName)), B && (mt = B(G, oe), X.attribs = oe = mt.attribs, G !== mt.tagName && (X.name = G = mt.tagName, ne[M] = mt.tagName)), (!S(G) || y.disallowedTagsMode === "recursiveEscape" && !p(Y) || y.nestingLimit != null && M >= y.nestingLimit) && (Ee = !0, Y[M] = !0, (y.disallowedTagsMode === "discard" || y.disallowedTagsMode === "completelyDiscard") && E.indexOf(G) !== -1 && (ie = !0, Ae = 1)), M++, Ee) {
49085
+ if (d(j, V) && (mt = j[V](V, oe), X.attribs = oe = mt.attribs, mt.text !== void 0 && (X.innerText = mt.text), V !== mt.tagName && (X.name = V = mt.tagName, ne[M] = mt.tagName)), B && (mt = B(V, oe), X.attribs = oe = mt.attribs, V !== mt.tagName && (X.name = V = mt.tagName, ne[M] = mt.tagName)), (!S(V) || y.disallowedTagsMode === "recursiveEscape" && !p(Y) || y.nestingLimit != null && M >= y.nestingLimit) && (Ee = !0, Y[M] = !0, (y.disallowedTagsMode === "discard" || y.disallowedTagsMode === "completelyDiscard") && E.indexOf(V) !== -1 && (ie = !0, Ae = 1)), M++, Ee) {
49101
49086
  if (y.disallowedTagsMode === "discard" || y.disallowedTagsMode === "completelyDiscard") {
49102
49087
  if (X.innerText && !gt) {
49103
49088
  const He = Ce(X.innerText);
49104
- y.textFilter ? v += y.textFilter(He, G) : v += He, ve = !0;
49089
+ y.textFilter ? v += y.textFilter(He, V) : v += He, ve = !0;
49105
49090
  }
49106
49091
  return;
49107
49092
  }
49108
49093
  A = v, v = "";
49109
49094
  }
49110
- v += "<" + G, G === "script" && (y.allowedScriptHostnames || y.allowedScriptDomains) && (X.innerText = ""), Ee && (y.disallowedTagsMode === "escape" || y.disallowedTagsMode === "recursiveEscape") && y.preserveEscapedAttributes ? l(oe, function(He, Le) {
49095
+ v += "<" + V, V === "script" && (y.allowedScriptHostnames || y.allowedScriptDomains) && (X.innerText = ""), Ee && (y.disallowedTagsMode === "escape" || y.disallowedTagsMode === "recursiveEscape") && y.preserveEscapedAttributes ? l(oe, function(He, Le) {
49111
49096
  v += " " + Le + '="' + Ce(He || "", !0) + '"';
49112
- }) : (!$ || d($, G) || $["*"]) && l(oe, function(He, Le) {
49097
+ }) : (!$ || d($, V) || $["*"]) && l(oe, function(He, Le) {
49113
49098
  if (!h.test(Le)) {
49114
49099
  delete X.attribs[Le];
49115
49100
  return;
@@ -49119,10 +49104,10 @@ and ensure you are accounting for this risk.
49119
49104
  return;
49120
49105
  }
49121
49106
  let Oo = !1;
49122
- if (!$ || d($, G) && $[G].indexOf(Le) !== -1 || $["*"] && $["*"].indexOf(Le) !== -1 || d(T, G) && T[G].test(Le) || T["*"] && T["*"].test(Le))
49107
+ if (!$ || d($, V) && $[V].indexOf(Le) !== -1 || $["*"] && $["*"].indexOf(Le) !== -1 || d(T, V) && T[V].test(Le) || T["*"] && T["*"].test(Le))
49123
49108
  Oo = !0;
49124
- else if ($ && $[G]) {
49125
- for (const Me of $[G])
49109
+ else if ($ && $[V]) {
49110
+ for (const Me of $[V])
49126
49111
  if (n(Me) && Me.name && Me.name === Le) {
49127
49112
  Oo = !0;
49128
49113
  let Ke = "";
@@ -49135,11 +49120,11 @@ and ensure you are accounting for this risk.
49135
49120
  }
49136
49121
  }
49137
49122
  if (Oo) {
49138
- if (y.allowedSchemesAppliedToAttributes.indexOf(Le) !== -1 && _e(G, He)) {
49123
+ if (y.allowedSchemesAppliedToAttributes.indexOf(Le) !== -1 && _e(V, He)) {
49139
49124
  delete X.attribs[Le];
49140
49125
  return;
49141
49126
  }
49142
- if (G === "script" && Le === "src") {
49127
+ if (V === "script" && Le === "src") {
49143
49128
  let Me = !0;
49144
49129
  try {
49145
49130
  const Ke = fe(He);
@@ -49159,7 +49144,7 @@ and ensure you are accounting for this risk.
49159
49144
  return;
49160
49145
  }
49161
49146
  }
49162
- if (G === "iframe" && Le === "src") {
49147
+ if (V === "iframe" && Le === "src") {
49163
49148
  let Me = !0;
49164
49149
  try {
49165
49150
  const Ke = fe(He);
@@ -49201,7 +49186,7 @@ and ensure you are accounting for this risk.
49201
49186
  return;
49202
49187
  }
49203
49188
  if (Le === "class") {
49204
- const Me = O[G], Ke = O["*"], Si = I[G], Cn = N[G], rn = N["*"], $r = I["*"], rd = [
49189
+ const Me = O[V], Ke = O["*"], Si = I[V], Cn = N[V], rn = N["*"], $r = I["*"], rd = [
49205
49190
  Si,
49206
49191
  $r
49207
49192
  ].concat(Cn, rn).filter(function(Mf) {
@@ -49223,7 +49208,7 @@ and ensure you are accounting for this risk.
49223
49208
  if (Le === "style") {
49224
49209
  if (y.parseStyleAttributes)
49225
49210
  try {
49226
- const Me = o(G + " {" + He + "}", { map: !1 }), Ke = Be(
49211
+ const Me = o(V + " {" + He + "}", { map: !1 }), Ke = Be(
49227
49212
  Me,
49228
49213
  y.allowedStyles
49229
49214
  );
@@ -49232,7 +49217,7 @@ and ensure you are accounting for this risk.
49232
49217
  return;
49233
49218
  }
49234
49219
  } catch {
49235
- typeof window < "u" && console.warn('Failed to parse "' + G + " {" + He + `}", If you're running this in a browser, we recommend to disable style parsing: options.parseStyleAttributes: false, since this only works in a node environment due to a postcss dependency, More info: https://github.com/apostrophecms/sanitize-html/issues/547`), delete X.attribs[Le];
49220
+ typeof window < "u" && console.warn('Failed to parse "' + V + " {" + He + `}", If you're running this in a browser, we recommend to disable style parsing: options.parseStyleAttributes: false, since this only works in a node environment due to a postcss dependency, More info: https://github.com/apostrophecms/sanitize-html/issues/547`), delete X.attribs[Le];
49236
49221
  return;
49237
49222
  }
49238
49223
  else if (y.allowedStyles)
@@ -49241,30 +49226,30 @@ and ensure you are accounting for this risk.
49241
49226
  v += " " + Le, He && He.length ? v += '="' + Ce(He, !0) + '"' : y.allowedEmptyAttributes.includes(Le) && (v += '=""');
49242
49227
  } else
49243
49228
  delete X.attribs[Le];
49244
- }), y.selfClosing.indexOf(G) !== -1 ? v += " />" : (v += ">", X.innerText && !gt && !y.textFilter && (v += Ce(X.innerText), ve = !0)), Ee && (v = A + Ce(v), A = ""), X.openingTagLength = v.length - X.tagPosition;
49229
+ }), y.selfClosing.indexOf(V) !== -1 ? v += " />" : (v += ">", X.innerText && !gt && !y.textFilter && (v += Ce(X.innerText), ve = !0)), Ee && (v = A + Ce(v), A = ""), X.openingTagLength = v.length - X.tagPosition;
49245
49230
  },
49246
- ontext: function(G) {
49231
+ ontext: function(V) {
49247
49232
  if (ie)
49248
49233
  return;
49249
49234
  const oe = H[H.length - 1];
49250
49235
  let X;
49251
- if (oe && (X = oe.tag, G = oe.innerText !== void 0 ? oe.innerText : G), y.disallowedTagsMode === "completelyDiscard" && !S(X))
49252
- G = "";
49236
+ if (oe && (X = oe.tag, V = oe.innerText !== void 0 ? oe.innerText : V), y.disallowedTagsMode === "completelyDiscard" && !S(X))
49237
+ V = "";
49253
49238
  else if ((y.disallowedTagsMode === "discard" || y.disallowedTagsMode === "completelyDiscard") && (X === "script" || X === "style"))
49254
- v += G;
49239
+ v += V;
49255
49240
  else if ((y.disallowedTagsMode === "discard" || y.disallowedTagsMode === "completelyDiscard") && (X === "textarea" || X === "xmp"))
49256
- v += G;
49241
+ v += V;
49257
49242
  else if (!ve) {
49258
- const Ee = Ce(G, !1);
49243
+ const Ee = Ce(V, !1);
49259
49244
  y.textFilter ? v += y.textFilter(Ee, X) : v += Ee;
49260
49245
  }
49261
49246
  if (H.length) {
49262
49247
  const Ee = H[H.length - 1];
49263
- Ee.text += G;
49248
+ Ee.text += V;
49264
49249
  }
49265
49250
  },
49266
- onclosetag: function(G, oe) {
49267
- if (y.onCloseTag && y.onCloseTag(G, oe), ie)
49251
+ onclosetag: function(V, oe) {
49252
+ if (y.onCloseTag && y.onCloseTag(V, oe), ie)
49268
49253
  if (Ae--, !Ae)
49269
49254
  ie = !1;
49270
49255
  else
@@ -49272,11 +49257,11 @@ and ensure you are accounting for this risk.
49272
49257
  const X = H.pop();
49273
49258
  if (!X)
49274
49259
  return;
49275
- if (X.tag !== G) {
49260
+ if (X.tag !== V) {
49276
49261
  H.push(X);
49277
49262
  return;
49278
49263
  }
49279
- ie = y.enforceHtmlBoundary ? G === "html" : !1, M--;
49264
+ ie = y.enforceHtmlBoundary ? V === "html" : !1, M--;
49280
49265
  const Ee = Y[M];
49281
49266
  if (Ee) {
49282
49267
  if (delete Y[M], y.disallowedTagsMode === "discard" || y.disallowedTagsMode === "completelyDiscard") {
@@ -49285,7 +49270,7 @@ and ensure you are accounting for this risk.
49285
49270
  }
49286
49271
  A = v, v = "";
49287
49272
  }
49288
- if (ne[M] && (G = ne[M], delete ne[M]), y.exclusiveFilter) {
49273
+ if (ne[M] && (V = ne[M], delete ne[M]), y.exclusiveFilter) {
49289
49274
  const gt = y.exclusiveFilter(X);
49290
49275
  if (gt === "excludeTag") {
49291
49276
  Ee && (v = A, A = ""), v = v.substring(0, X.tagPosition) + v.substring(X.tagPosition + X.openingTagLength);
@@ -49296,29 +49281,29 @@ and ensure you are accounting for this risk.
49296
49281
  }
49297
49282
  }
49298
49283
  if (X.updateParentNodeMediaChildren(), X.updateParentNodeText(), // Already output />
49299
- y.selfClosing.indexOf(G) !== -1 || // Escaped tag, closing tag is implied
49300
- oe && !S(G) && ["escape", "recursiveEscape"].indexOf(y.disallowedTagsMode) >= 0) {
49284
+ y.selfClosing.indexOf(V) !== -1 || // Escaped tag, closing tag is implied
49285
+ oe && !S(V) && ["escape", "recursiveEscape"].indexOf(y.disallowedTagsMode) >= 0) {
49301
49286
  Ee && (v = A, A = "");
49302
49287
  return;
49303
49288
  }
49304
- v += "</" + G + ">", Ee && (v = A + Ce(v), A = ""), ve = !1;
49289
+ v += "</" + V + ">", Ee && (v = A + Ce(v), A = ""), ve = !1;
49305
49290
  }
49306
49291
  }, y.parser);
49307
49292
  if (Pe.write(_), Pe.end(), y.disallowedTagsMode === "escape" || y.disallowedTagsMode === "recursiveEscape") {
49308
- const G = Pe.endIndex;
49309
- if (G != null && G >= 0 && G < _.length) {
49310
- const oe = _.substring(G);
49293
+ const V = Pe.endIndex;
49294
+ if (V != null && V >= 0 && V < _.length) {
49295
+ const oe = _.substring(V);
49311
49296
  v += Ce(oe);
49312
- } else (G == null || G < 0) && _.length > 0 && v === "" && (v = Ce(_));
49297
+ } else (V == null || V < 0) && _.length > 0 && v === "" && (v = Ce(_));
49313
49298
  }
49314
49299
  return v;
49315
49300
  function K() {
49316
49301
  v = "", M = 0, H = [], Y = {}, ne = {}, ie = !1, Ae = 0;
49317
49302
  }
49318
- function Ce(G, oe) {
49319
- return typeof G != "string" && (G = G + ""), y.parser.decodeEntities && (G = G.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"), oe && (G = G.replace(/"/g, "&quot;"))), G = G.replace(/&(?![a-zA-Z0-9#]{1,20};)/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"), oe && (G = G.replace(/"/g, "&quot;")), G;
49303
+ function Ce(V, oe) {
49304
+ return typeof V != "string" && (V = V + ""), y.parser.decodeEntities && (V = V.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"), oe && (V = V.replace(/"/g, "&quot;"))), V = V.replace(/&(?![a-zA-Z0-9#]{1,20};)/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"), oe && (V = V.replace(/"/g, "&quot;")), V;
49320
49305
  }
49321
- function _e(G, oe) {
49306
+ function _e(V, oe) {
49322
49307
  for (oe = oe.replace(/[\x00-\x20]+/g, ""); ; ) {
49323
49308
  const gt = oe.indexOf("<!--");
49324
49309
  if (gt === -1)
@@ -49332,50 +49317,50 @@ and ensure you are accounting for this risk.
49332
49317
  if (!X)
49333
49318
  return oe.match(/^[/\\]{2}/) ? !y.allowProtocolRelative : !1;
49334
49319
  const Ee = X[1].toLowerCase();
49335
- return d(y.allowedSchemesByTag, G) ? y.allowedSchemesByTag[G].indexOf(Ee) === -1 : !y.allowedSchemes || y.allowedSchemes.indexOf(Ee) === -1;
49320
+ return d(y.allowedSchemesByTag, V) ? y.allowedSchemesByTag[V].indexOf(Ee) === -1 : !y.allowedSchemes || y.allowedSchemes.indexOf(Ee) === -1;
49336
49321
  }
49337
- function fe(G) {
49338
- if (G = G.replace(/^(\w+:)?\s*[\\/]\s*[\\/]/, "$1//"), G.startsWith("relative:"))
49322
+ function fe(V) {
49323
+ if (V = V.replace(/^(\w+:)?\s*[\\/]\s*[\\/]/, "$1//"), V.startsWith("relative:"))
49339
49324
  throw new Error("relative: exploit attempt");
49340
49325
  let oe = "relative://relative-site";
49341
49326
  for (let gt = 0; gt < 100; gt++)
49342
49327
  oe += `/${gt}`;
49343
- const X = new URL(G, oe);
49328
+ const X = new URL(V, oe);
49344
49329
  return {
49345
49330
  isRelativeUrl: X && X.hostname === "relative-site" && X.protocol === "relative:",
49346
49331
  url: X
49347
49332
  };
49348
49333
  }
49349
- function Be(G, oe) {
49334
+ function Be(V, oe) {
49350
49335
  if (!oe)
49351
- return G;
49352
- const X = G.nodes[0];
49336
+ return V;
49337
+ const X = V.nodes[0];
49353
49338
  let Ee;
49354
49339
  return oe[X.selector] && oe["*"] ? Ee = i(
49355
49340
  oe[X.selector],
49356
49341
  oe["*"]
49357
- ) : Ee = oe[X.selector] || oe["*"], Ee && (G.nodes[0].nodes = X.nodes.reduce(Xe(Ee), [])), G;
49342
+ ) : Ee = oe[X.selector] || oe["*"], Ee && (V.nodes[0].nodes = X.nodes.reduce(Xe(Ee), [])), V;
49358
49343
  }
49359
- function nt(G) {
49360
- return G.nodes[0].nodes.reduce(function(oe, X) {
49344
+ function nt(V) {
49345
+ return V.nodes[0].nodes.reduce(function(oe, X) {
49361
49346
  return oe.push(
49362
49347
  `${X.prop}:${X.value}${X.important ? " !important" : ""}`
49363
49348
  ), oe;
49364
49349
  }, []).join(";");
49365
49350
  }
49366
- function Xe(G) {
49351
+ function Xe(V) {
49367
49352
  return function(oe, X) {
49368
- return d(G, X.prop) && G[X.prop].some(function(gt) {
49353
+ return d(V, X.prop) && V[X.prop].some(function(gt) {
49369
49354
  return gt.test(X.value);
49370
49355
  }) && oe.push(X), oe;
49371
49356
  };
49372
49357
  }
49373
- function hn(G, oe, X) {
49374
- return oe ? (G = G.split(/\s+/), G.filter(function(Ee) {
49358
+ function hn(V, oe, X) {
49359
+ return oe ? (V = V.split(/\s+/), V.filter(function(Ee) {
49375
49360
  return oe.indexOf(Ee) !== -1 || X.some(function(gt) {
49376
49361
  return gt.test(Ee);
49377
49362
  });
49378
- }).join(" ")) : G;
49363
+ }).join(" ")) : V;
49379
49364
  }
49380
49365
  }
49381
49366
  const m = {
@@ -51629,7 +51614,7 @@ const vz = {
51629
51614
  } catch {
51630
51615
  }
51631
51616
  let f = c.unexpectedError();
51632
- if (u instanceof V)
51617
+ if (u instanceof G)
51633
51618
  try {
51634
51619
  const h = JSON.parse(u.message);
51635
51620
  h.message && (f = h.message);
@@ -62505,7 +62490,7 @@ function XT(e) {
62505
62490
  if (!e) return null;
62506
62491
  try {
62507
62492
  const n = JSON.parse(e).connect;
62508
- if (n && typeof n == "object" && typeof n.integration_type == "string" && typeof n.domain == "string" && typeof n.return_to == "string" && typeof n.caller_state == "string")
62493
+ if (n && typeof n == "object" && (n.integration_type === void 0 || typeof n.integration_type == "string") && typeof n.domain == "string" && typeof n.return_to == "string" && typeof n.caller_state == "string")
62509
62494
  return n;
62510
62495
  } catch {
62511
62496
  }
@@ -62568,7 +62553,7 @@ async function Fr(e) {
62568
62553
  config: {
62569
62554
  content: `
62570
62555
  <div style="display:flex;flex-direction:column;gap:12px;padding:16px;border:1px solid #e5e7eb;border-radius:8px;background:#f9fafb">
62571
- <div style="font-size:14px;color:#6b7280">${Ie(f.integration_type)}</div>
62556
+ ${f.integration_type ? `<div style="font-size:14px;color:#6b7280">${Ie(f.integration_type)}</div>` : ""}
62572
62557
  <div style="font-size:18px;font-weight:600;color:#111827">${Ie(f.domain)}${_}</div>
62573
62558
  <div style="font-size:14px;color:#374151">wants to connect to your ${Ie(n.friendly_name)} account as <span style="font-weight:500">${Ie(u.email || u.name || u.user_id)}</span>.</div>
62574
62559
  ${w}
@@ -62650,10 +62635,9 @@ async function xK(e, t) {
62650
62635
  }
62651
62636
  const p = {
62652
62637
  domain: d.domain,
62653
- integration_type: d.integration_type,
62654
62638
  grant_types: ["client_credentials"]
62655
62639
  };
62656
- d.scope && (p.scope = d.scope);
62640
+ d.integration_type && (p.integration_type = d.integration_type), d.scope && (p.scope = d.scope);
62657
62641
  const f = await YE(
62658
62642
  Ua(n.env.data),
62659
62643
  u,
@@ -62730,7 +62714,7 @@ function t6(e) {
62730
62714
  if (!e) return null;
62731
62715
  try {
62732
62716
  const n = JSON.parse(e).connect;
62733
- if (n && typeof n == "object" && typeof n.integration_type == "string" && typeof n.domain == "string" && typeof n.return_to == "string" && typeof n.caller_state == "string")
62717
+ if (n && typeof n == "object" && (n.integration_type === void 0 || typeof n.integration_type == "string") && typeof n.domain == "string" && typeof n.return_to == "string" && typeof n.caller_state == "string")
62734
62718
  return n;
62735
62719
  } catch {
62736
62720
  }