@authhero/kysely-adapter 10.129.0 → 10.130.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.
@@ -353,6 +353,8 @@ declare const auditEventInsertSchema: z.ZodObject<{
353
353
  connection: z.ZodOptional<z.ZodString>;
354
354
  strategy: z.ZodOptional<z.ZodString>;
355
355
  strategy_type: z.ZodOptional<z.ZodString>;
356
+ audience: z.ZodOptional<z.ZodString>;
357
+ scope: z.ZodOptional<z.ZodString>;
356
358
  location: z.ZodOptional<z.ZodObject<{
357
359
  country_code: z.ZodString;
358
360
  city_name: z.ZodString;
@@ -434,6 +436,8 @@ declare const auditEventInsertSchema: z.ZodObject<{
434
436
  connection?: string | undefined;
435
437
  strategy?: string | undefined;
436
438
  strategy_type?: string | undefined;
439
+ audience?: string | undefined;
440
+ scope?: string | undefined;
437
441
  location?: {
438
442
  country_code: string;
439
443
  city_name: string;
@@ -491,6 +495,8 @@ declare const auditEventInsertSchema: z.ZodObject<{
491
495
  connection?: string | undefined;
492
496
  strategy?: string | undefined;
493
497
  strategy_type?: string | undefined;
498
+ audience?: string | undefined;
499
+ scope?: string | undefined;
494
500
  location?: {
495
501
  country_code: string;
496
502
  city_name: string;
@@ -621,6 +627,8 @@ declare const auditEventSchema: z.ZodObject<{
621
627
  connection: z.ZodOptional<z.ZodString>;
622
628
  strategy: z.ZodOptional<z.ZodString>;
623
629
  strategy_type: z.ZodOptional<z.ZodString>;
630
+ audience: z.ZodOptional<z.ZodString>;
631
+ scope: z.ZodOptional<z.ZodString>;
624
632
  location: z.ZodOptional<z.ZodObject<{
625
633
  country_code: z.ZodString;
626
634
  city_name: z.ZodString;
@@ -705,6 +713,8 @@ declare const auditEventSchema: z.ZodObject<{
705
713
  connection?: string | undefined;
706
714
  strategy?: string | undefined;
707
715
  strategy_type?: string | undefined;
716
+ audience?: string | undefined;
717
+ scope?: string | undefined;
708
718
  location?: {
709
719
  country_code: string;
710
720
  city_name: string;
@@ -763,6 +773,8 @@ declare const auditEventSchema: z.ZodObject<{
763
773
  connection?: string | undefined;
764
774
  strategy?: string | undefined;
765
775
  strategy_type?: string | undefined;
776
+ audience?: string | undefined;
777
+ scope?: string | undefined;
766
778
  location?: {
767
779
  country_code: string;
768
780
  city_name: string;
@@ -2180,8 +2192,8 @@ declare const clientGrantInsertSchema: z.ZodObject<{
2180
2192
  }, "strip", z.ZodTypeAny, {
2181
2193
  client_id: string;
2182
2194
  audience: string;
2183
- organization_usage?: "deny" | "allow" | "require" | undefined;
2184
2195
  scope?: string[] | undefined;
2196
+ organization_usage?: "deny" | "allow" | "require" | undefined;
2185
2197
  allow_any_organization?: boolean | undefined;
2186
2198
  is_system?: boolean | undefined;
2187
2199
  subject_type?: "user" | "client" | undefined;
@@ -2189,8 +2201,8 @@ declare const clientGrantInsertSchema: z.ZodObject<{
2189
2201
  }, {
2190
2202
  client_id: string;
2191
2203
  audience: string;
2192
- organization_usage?: "deny" | "allow" | "require" | undefined;
2193
2204
  scope?: string[] | undefined;
2205
+ organization_usage?: "deny" | "allow" | "require" | undefined;
2194
2206
  allow_any_organization?: boolean | undefined;
2195
2207
  is_system?: boolean | undefined;
2196
2208
  subject_type?: "user" | "client" | undefined;
@@ -2222,8 +2234,8 @@ declare const clientGrantSchema: z.ZodObject<{
2222
2234
  audience: string;
2223
2235
  created_at?: string | undefined;
2224
2236
  updated_at?: string | undefined;
2225
- organization_usage?: "deny" | "allow" | "require" | undefined;
2226
2237
  scope?: string[] | undefined;
2238
+ organization_usage?: "deny" | "allow" | "require" | undefined;
2227
2239
  allow_any_organization?: boolean | undefined;
2228
2240
  is_system?: boolean | undefined;
2229
2241
  subject_type?: "user" | "client" | undefined;
@@ -2234,8 +2246,8 @@ declare const clientGrantSchema: z.ZodObject<{
2234
2246
  audience: string;
2235
2247
  created_at?: string | undefined;
2236
2248
  updated_at?: string | undefined;
2237
- organization_usage?: "deny" | "allow" | "require" | undefined;
2238
2249
  scope?: string[] | undefined;
2250
+ organization_usage?: "deny" | "allow" | "require" | undefined;
2239
2251
  allow_any_organization?: boolean | undefined;
2240
2252
  is_system?: boolean | undefined;
2241
2253
  subject_type?: "user" | "client" | undefined;
@@ -2901,9 +2913,9 @@ declare const connectionInsertSchema: z.ZodObject<{
2901
2913
  } | undefined;
2902
2914
  } | undefined;
2903
2915
  client_id?: string | undefined;
2916
+ scope?: string | undefined;
2904
2917
  provider?: string | undefined;
2905
2918
  client_secret?: string | undefined;
2906
- scope?: string | undefined;
2907
2919
  kid?: string | undefined;
2908
2920
  team_id?: string | undefined;
2909
2921
  realms?: string | undefined;
@@ -3004,9 +3016,9 @@ declare const connectionInsertSchema: z.ZodObject<{
3004
3016
  } | undefined;
3005
3017
  } | undefined;
3006
3018
  client_id?: string | undefined;
3019
+ scope?: string | undefined;
3007
3020
  provider?: string | undefined;
3008
3021
  client_secret?: string | undefined;
3009
- scope?: string | undefined;
3010
3022
  kid?: string | undefined;
3011
3023
  team_id?: string | undefined;
3012
3024
  realms?: string | undefined;
@@ -3116,9 +3128,9 @@ declare const connectionInsertSchema: z.ZodObject<{
3116
3128
  } | undefined;
3117
3129
  } | undefined;
3118
3130
  client_id?: string | undefined;
3131
+ scope?: string | undefined;
3119
3132
  provider?: string | undefined;
3120
3133
  client_secret?: string | undefined;
3121
- scope?: string | undefined;
3122
3134
  kid?: string | undefined;
3123
3135
  team_id?: string | undefined;
3124
3136
  realms?: string | undefined;
@@ -3234,9 +3246,9 @@ declare const connectionInsertSchema: z.ZodObject<{
3234
3246
  } | undefined;
3235
3247
  } | undefined;
3236
3248
  client_id?: string | undefined;
3249
+ scope?: string | undefined;
3237
3250
  provider?: string | undefined;
3238
3251
  client_secret?: string | undefined;
3239
- scope?: string | undefined;
3240
3252
  kid?: string | undefined;
3241
3253
  team_id?: string | undefined;
3242
3254
  realms?: string | undefined;
@@ -3777,9 +3789,9 @@ declare const connectionSchema: z.ZodObject<{
3777
3789
  } | undefined;
3778
3790
  } | undefined;
3779
3791
  client_id?: string | undefined;
3792
+ scope?: string | undefined;
3780
3793
  provider?: string | undefined;
3781
3794
  client_secret?: string | undefined;
3782
- scope?: string | undefined;
3783
3795
  kid?: string | undefined;
3784
3796
  team_id?: string | undefined;
3785
3797
  realms?: string | undefined;
@@ -3880,9 +3892,9 @@ declare const connectionSchema: z.ZodObject<{
3880
3892
  } | undefined;
3881
3893
  } | undefined;
3882
3894
  client_id?: string | undefined;
3895
+ scope?: string | undefined;
3883
3896
  provider?: string | undefined;
3884
3897
  client_secret?: string | undefined;
3885
- scope?: string | undefined;
3886
3898
  kid?: string | undefined;
3887
3899
  team_id?: string | undefined;
3888
3900
  realms?: string | undefined;
@@ -3994,9 +4006,9 @@ declare const connectionSchema: z.ZodObject<{
3994
4006
  } | undefined;
3995
4007
  } | undefined;
3996
4008
  client_id?: string | undefined;
4009
+ scope?: string | undefined;
3997
4010
  provider?: string | undefined;
3998
4011
  client_secret?: string | undefined;
3999
- scope?: string | undefined;
4000
4012
  kid?: string | undefined;
4001
4013
  team_id?: string | undefined;
4002
4014
  realms?: string | undefined;
@@ -4114,9 +4126,9 @@ declare const connectionSchema: z.ZodObject<{
4114
4126
  } | undefined;
4115
4127
  } | undefined;
4116
4128
  client_id?: string | undefined;
4129
+ scope?: string | undefined;
4117
4130
  provider?: string | undefined;
4118
4131
  client_secret?: string | undefined;
4119
- scope?: string | undefined;
4120
4132
  kid?: string | undefined;
4121
4133
  team_id?: string | undefined;
4122
4134
  realms?: string | undefined;
@@ -15701,9 +15713,9 @@ declare const loginSessionInsertSchema: z.ZodObject<{
15701
15713
  vendor_id: z.ZodOptional<z.ZodString>;
15702
15714
  }, "strip", z.ZodTypeAny, {
15703
15715
  client_id: string;
15704
- username?: string | undefined;
15705
15716
  audience?: string | undefined;
15706
15717
  scope?: string | undefined;
15718
+ username?: string | undefined;
15707
15719
  act_as?: string | undefined;
15708
15720
  response_type?: AuthorizationResponseType | undefined;
15709
15721
  response_mode?: AuthorizationResponseMode | undefined;
@@ -15720,9 +15732,9 @@ declare const loginSessionInsertSchema: z.ZodObject<{
15720
15732
  vendor_id?: string | undefined;
15721
15733
  }, {
15722
15734
  client_id: string;
15723
- username?: string | undefined;
15724
15735
  audience?: string | undefined;
15725
15736
  scope?: string | undefined;
15737
+ username?: string | undefined;
15726
15738
  act_as?: string | undefined;
15727
15739
  response_type?: AuthorizationResponseType | undefined;
15728
15740
  response_mode?: AuthorizationResponseMode | undefined;
@@ -15766,9 +15778,9 @@ declare const loginSessionInsertSchema: z.ZodObject<{
15766
15778
  csrf_token: string;
15767
15779
  authParams: {
15768
15780
  client_id: string;
15769
- username?: string | undefined;
15770
15781
  audience?: string | undefined;
15771
15782
  scope?: string | undefined;
15783
+ username?: string | undefined;
15772
15784
  act_as?: string | undefined;
15773
15785
  response_type?: AuthorizationResponseType | undefined;
15774
15786
  response_mode?: AuthorizationResponseMode | undefined;
@@ -15804,9 +15816,9 @@ declare const loginSessionInsertSchema: z.ZodObject<{
15804
15816
  csrf_token: string;
15805
15817
  authParams: {
15806
15818
  client_id: string;
15807
- username?: string | undefined;
15808
15819
  audience?: string | undefined;
15809
15820
  scope?: string | undefined;
15821
+ username?: string | undefined;
15810
15822
  act_as?: string | undefined;
15811
15823
  response_type?: AuthorizationResponseType | undefined;
15812
15824
  response_mode?: AuthorizationResponseMode | undefined;
@@ -15867,9 +15879,9 @@ declare const loginSessionSchema: z.ZodObject<{
15867
15879
  vendor_id: z.ZodOptional<z.ZodString>;
15868
15880
  }, "strip", z.ZodTypeAny, {
15869
15881
  client_id: string;
15870
- username?: string | undefined;
15871
15882
  audience?: string | undefined;
15872
15883
  scope?: string | undefined;
15884
+ username?: string | undefined;
15873
15885
  act_as?: string | undefined;
15874
15886
  response_type?: AuthorizationResponseType | undefined;
15875
15887
  response_mode?: AuthorizationResponseMode | undefined;
@@ -15886,9 +15898,9 @@ declare const loginSessionSchema: z.ZodObject<{
15886
15898
  vendor_id?: string | undefined;
15887
15899
  }, {
15888
15900
  client_id: string;
15889
- username?: string | undefined;
15890
15901
  audience?: string | undefined;
15891
15902
  scope?: string | undefined;
15903
+ username?: string | undefined;
15892
15904
  act_as?: string | undefined;
15893
15905
  response_type?: AuthorizationResponseType | undefined;
15894
15906
  response_mode?: AuthorizationResponseMode | undefined;
@@ -15935,9 +15947,9 @@ declare const loginSessionSchema: z.ZodObject<{
15935
15947
  csrf_token: string;
15936
15948
  authParams: {
15937
15949
  client_id: string;
15938
- username?: string | undefined;
15939
15950
  audience?: string | undefined;
15940
15951
  scope?: string | undefined;
15952
+ username?: string | undefined;
15941
15953
  act_as?: string | undefined;
15942
15954
  response_type?: AuthorizationResponseType | undefined;
15943
15955
  response_mode?: AuthorizationResponseMode | undefined;
@@ -15976,9 +15988,9 @@ declare const loginSessionSchema: z.ZodObject<{
15976
15988
  csrf_token: string;
15977
15989
  authParams: {
15978
15990
  client_id: string;
15979
- username?: string | undefined;
15980
15991
  audience?: string | undefined;
15981
15992
  scope?: string | undefined;
15993
+ username?: string | undefined;
15982
15994
  act_as?: string | undefined;
15983
15995
  response_type?: AuthorizationResponseType | undefined;
15984
15996
  response_mode?: AuthorizationResponseMode | undefined;
@@ -16088,6 +16100,8 @@ declare const logInsertSchema: z.ZodObject<{
16088
16100
  connection?: string | undefined;
16089
16101
  strategy?: string | undefined;
16090
16102
  strategy_type?: string | undefined;
16103
+ audience?: string | undefined;
16104
+ scope?: string | undefined;
16091
16105
  auth0_client?: {
16092
16106
  version: string;
16093
16107
  name: string;
@@ -16098,8 +16112,6 @@ declare const logInsertSchema: z.ZodObject<{
16098
16112
  hostname?: string | undefined;
16099
16113
  connection_id?: string | undefined;
16100
16114
  user_id?: string | undefined;
16101
- audience?: string | undefined;
16102
- scope?: string | undefined;
16103
16115
  details?: any;
16104
16116
  user_name?: string | undefined;
16105
16117
  client_name?: string | undefined;
@@ -16123,6 +16135,8 @@ declare const logInsertSchema: z.ZodObject<{
16123
16135
  connection?: string | undefined;
16124
16136
  strategy?: string | undefined;
16125
16137
  strategy_type?: string | undefined;
16138
+ audience?: string | undefined;
16139
+ scope?: string | undefined;
16126
16140
  auth0_client?: {
16127
16141
  version: string;
16128
16142
  name: string;
@@ -16133,8 +16147,6 @@ declare const logInsertSchema: z.ZodObject<{
16133
16147
  hostname?: string | undefined;
16134
16148
  connection_id?: string | undefined;
16135
16149
  user_id?: string | undefined;
16136
- audience?: string | undefined;
16137
- scope?: string | undefined;
16138
16150
  details?: any;
16139
16151
  user_name?: string | undefined;
16140
16152
  client_name?: string | undefined;
@@ -16226,6 +16238,8 @@ declare const logSchema: z.ZodObject<{
16226
16238
  connection?: string | undefined;
16227
16239
  strategy?: string | undefined;
16228
16240
  strategy_type?: string | undefined;
16241
+ audience?: string | undefined;
16242
+ scope?: string | undefined;
16229
16243
  auth0_client?: {
16230
16244
  version: string;
16231
16245
  name: string;
@@ -16236,8 +16250,6 @@ declare const logSchema: z.ZodObject<{
16236
16250
  hostname?: string | undefined;
16237
16251
  connection_id?: string | undefined;
16238
16252
  user_id?: string | undefined;
16239
- audience?: string | undefined;
16240
- scope?: string | undefined;
16241
16253
  details?: any;
16242
16254
  user_name?: string | undefined;
16243
16255
  client_name?: string | undefined;
@@ -16261,6 +16273,8 @@ declare const logSchema: z.ZodObject<{
16261
16273
  connection?: string | undefined;
16262
16274
  strategy?: string | undefined;
16263
16275
  strategy_type?: string | undefined;
16276
+ audience?: string | undefined;
16277
+ scope?: string | undefined;
16264
16278
  auth0_client?: {
16265
16279
  version: string;
16266
16280
  name: string;
@@ -16271,8 +16285,6 @@ declare const logSchema: z.ZodObject<{
16271
16285
  hostname?: string | undefined;
16272
16286
  connection_id?: string | undefined;
16273
16287
  user_id?: string | undefined;
16274
- audience?: string | undefined;
16275
- scope?: string | undefined;
16276
16288
  details?: any;
16277
16289
  user_name?: string | undefined;
16278
16290
  client_name?: string | undefined;
@@ -19441,11 +19453,23 @@ export interface EmailProvidersAdapter {
19441
19453
  export interface ListRefreshTokenResponse extends Totals {
19442
19454
  refresh_tokens: RefreshToken[];
19443
19455
  }
19456
+ export interface UpdateRefreshTokenOptions {
19457
+ /**
19458
+ * When provided, the adapter also extends the parent login_session's
19459
+ * `expires_at` to `expires_at` (only if the current value is smaller).
19460
+ * The caller is expected to compute the new expiry so the adapter can
19461
+ * avoid a read-before-write and parallelise the two UPDATEs.
19462
+ */
19463
+ loginSessionBump?: {
19464
+ login_id: string;
19465
+ expires_at: string;
19466
+ };
19467
+ }
19444
19468
  export interface RefreshTokensAdapter {
19445
19469
  create: (tenant_id: string, refresh_token: RefreshTokenInsert) => Promise<RefreshToken>;
19446
19470
  get: (tenant_id: string, id: string) => Promise<RefreshToken | null>;
19447
19471
  list(tenant_id: string, params?: ListParams): Promise<ListRefreshTokenResponse>;
19448
- update: (tenant_id: string, id: string, refresh_token: Partial<RefreshToken>) => Promise<boolean>;
19472
+ update: (tenant_id: string, id: string, refresh_token: Partial<RefreshToken>, options?: UpdateRefreshTokenOptions) => Promise<boolean>;
19449
19473
  remove: (tenant_id: string, id: string) => Promise<boolean>;
19450
19474
  revokeByLoginSession: (tenant_id: string, login_session_id: string, revoked_at: string) => Promise<number>;
19451
19475
  }
@@ -87,7 +87,7 @@ function fe(e) {
87
87
  function F(e, t = (/* @__PURE__ */ new Date(0)).toISOString()) {
88
88
  return fe(e) ?? t;
89
89
  }
90
- function N(e) {
90
+ function C(e) {
91
91
  if (!e || e === "")
92
92
  return null;
93
93
  const t = new Date(e);
@@ -241,8 +241,8 @@ function at(e) {
241
241
  deployed_at_ts: f,
242
242
  secrets: g,
243
243
  dependencies: v,
244
- supported_triggers: C,
245
- tenant_id: x,
244
+ supported_triggers: N,
245
+ tenant_id: T,
246
246
  ...b
247
247
  } = m, I = D({ created_at_ts: _, updated_at_ts: p }, [
248
248
  "created_at_ts",
@@ -260,7 +260,7 @@ function at(e) {
260
260
  v
261
261
  ),
262
262
  supported_triggers: H(
263
- C
263
+ N
264
264
  )
265
265
  };
266
266
  });
@@ -963,10 +963,10 @@ function zt(e) {
963
963
  updated_at_ts: n,
964
964
  authenticated_at_ts: n,
965
965
  last_interaction_at_ts: n,
966
- expires_at_ts: N(s),
967
- idle_expires_at_ts: N(i),
968
- used_at_ts: N(u),
969
- revoked_at_ts: N(d),
966
+ expires_at_ts: C(s),
967
+ idle_expires_at_ts: C(i),
968
+ used_at_ts: C(u),
969
+ revoked_at_ts: C(d),
970
970
  device: JSON.stringify(c),
971
971
  clients: JSON.stringify(l)
972
972
  }).execute(), r;
@@ -982,9 +982,9 @@ function At(e) {
982
982
  device: n.device ? JSON.stringify(n.device) : void 0,
983
983
  clients: n.clients ? JSON.stringify(n.clients) : void 0
984
984
  };
985
- return n.expires_at !== void 0 && (o.expires_at_ts = N(n.expires_at)), n.idle_expires_at !== void 0 && (o.idle_expires_at_ts = N(n.idle_expires_at)), n.authenticated_at !== void 0 && (o.authenticated_at_ts = N(n.authenticated_at)), n.last_interaction_at !== void 0 && (o.last_interaction_at_ts = N(
985
+ return n.expires_at !== void 0 && (o.expires_at_ts = C(n.expires_at)), n.idle_expires_at !== void 0 && (o.idle_expires_at_ts = C(n.idle_expires_at)), n.authenticated_at !== void 0 && (o.authenticated_at_ts = C(n.authenticated_at)), n.last_interaction_at !== void 0 && (o.last_interaction_at_ts = C(
986
986
  n.last_interaction_at
987
- )), n.used_at !== void 0 && (o.used_at_ts = N(n.used_at)), n.revoked_at !== void 0 && (o.revoked_at_ts = N(n.revoked_at)), n.user_id !== void 0 && (o.user_id = n.user_id), n.login_session_id !== void 0 && (o.login_session_id = n.login_session_id), !!(await e.updateTable("sessions").set(o).where("tenant_id", "=", t).where("sessions.id", "=", a).execute()).length;
987
+ )), n.used_at !== void 0 && (o.used_at_ts = C(n.used_at)), n.revoked_at !== void 0 && (o.revoked_at_ts = C(n.revoked_at)), n.user_id !== void 0 && (o.user_id = n.user_id), n.login_session_id !== void 0 && (o.login_session_id = n.login_session_id), !!(await e.updateTable("sessions").set(o).where("tenant_id", "=", t).where("sessions.id", "=", a).execute()).length;
988
988
  };
989
989
  }
990
990
  function Ft(e) {
@@ -1003,22 +1003,22 @@ function Ft(e) {
1003
1003
  tenant_id: f,
1004
1004
  device: g,
1005
1005
  clients: v,
1006
- created_at_ts: C,
1007
- updated_at_ts: x,
1006
+ created_at_ts: N,
1007
+ updated_at_ts: T,
1008
1008
  expires_at_ts: b,
1009
1009
  idle_expires_at_ts: I,
1010
- authenticated_at_ts: T,
1010
+ authenticated_at_ts: x,
1011
1011
  last_interaction_at_ts: A,
1012
1012
  used_at_ts: ae,
1013
1013
  revoked_at_ts: De,
1014
1014
  ...Ae
1015
1015
  } = p, Fe = D(
1016
1016
  {
1017
- created_at_ts: C,
1018
- updated_at_ts: x,
1017
+ created_at_ts: N,
1018
+ updated_at_ts: T,
1019
1019
  expires_at_ts: b,
1020
1020
  idle_expires_at_ts: I,
1021
- authenticated_at_ts: T,
1021
+ authenticated_at_ts: x,
1022
1022
  last_interaction_at_ts: A,
1023
1023
  used_at_ts: ae,
1024
1024
  revoked_at_ts: De
@@ -1687,14 +1687,14 @@ function wa(e) {
1687
1687
  const { page: n = 0, per_page: o = 50, include_totals: r = !1, q: s, sort: i } = a;
1688
1688
  let u = e.selectFrom("client_grants").where("client_grants.tenant_id", "=", t);
1689
1689
  if (s) {
1690
- const _ = s.trim(), p = _.split(/\s+/), f = p.length === 1 ? p[0] : void 0, g = f ? f.match(/^(-)?([a-zA-Z_][a-zA-Z0-9_]*):"?([^"]*)"?$/) : null, v = g ? g[3] : "", C = /^(>=|>|<=|<)/.test(v || "");
1691
- if (g && !C && v) {
1692
- const x = !!g[1], b = g[2], { ref: I } = e.dynamic, T = I(`client_grants.${b}`);
1690
+ const _ = s.trim(), p = _.split(/\s+/), f = p.length === 1 ? p[0] : void 0, g = f ? f.match(/^(-)?([a-zA-Z_][a-zA-Z0-9_]*):"?([^"]*)"?$/) : null, v = g ? g[3] : "", N = /^(>=|>|<=|<)/.test(v || "");
1691
+ if (g && !N && v) {
1692
+ const T = !!g[1], b = g[2], { ref: I } = e.dynamic, x = I(`client_grants.${b}`);
1693
1693
  if (b === "allow_any_organization") {
1694
1694
  const A = v === "true" ? 1 : 0;
1695
- x ? u = u.where(T, "!=", A) : u = u.where(T, "=", A);
1695
+ T ? u = u.where(x, "!=", A) : u = u.where(x, "=", A);
1696
1696
  } else
1697
- x ? u = u.where(T, "!=", v) : u = u.where(T, "=", v);
1697
+ T ? u = u.where(x, "!=", v) : u = u.where(x, "=", v);
1698
1698
  } else
1699
1699
  u = $(e, u, _, []);
1700
1700
  }
@@ -1937,7 +1937,7 @@ function za(e) {
1937
1937
  }
1938
1938
  function Da(e) {
1939
1939
  return async (t, a) => {
1940
- var s, i, u, d, c, l, m, _, p, f, g, v, C, x, b, I, T, A;
1940
+ var s, i, u, d, c, l, m, _, p, f, g, v, N, T, b, I, x, A;
1941
1941
  const { colors: n, font: o, ...r } = a;
1942
1942
  try {
1943
1943
  await e.insertInto("branding").values({
@@ -1955,9 +1955,9 @@ function Da(e) {
1955
1955
  ...r,
1956
1956
  colors_primary: n == null ? void 0 : n.primary,
1957
1957
  colors_page_background_type: (g = (f = a.colors) == null ? void 0 : f.page_background) == null ? void 0 : g.type,
1958
- colors_page_background_start: (C = (v = a.colors) == null ? void 0 : v.page_background) == null ? void 0 : C.start,
1959
- colors_page_background_end: (b = (x = a.colors) == null ? void 0 : x.page_background) == null ? void 0 : b.end,
1960
- colors_page_background_angle_dev: (T = (I = a.colors) == null ? void 0 : I.page_background) == null ? void 0 : T.angle_deg,
1958
+ colors_page_background_start: (N = (v = a.colors) == null ? void 0 : v.page_background) == null ? void 0 : N.start,
1959
+ colors_page_background_end: (b = (T = a.colors) == null ? void 0 : T.page_background) == null ? void 0 : b.end,
1960
+ colors_page_background_angle_dev: (x = (I = a.colors) == null ? void 0 : I.page_background) == null ? void 0 : x.angle_deg,
1961
1961
  font_url: (A = a.font) == null ? void 0 : A.url
1962
1962
  }).where("tenant_id", "=", t).execute();
1963
1963
  }
@@ -2024,14 +2024,14 @@ function Ja(e) {
2024
2024
  synchronous: f,
2025
2025
  created_at_ts: g,
2026
2026
  updated_at_ts: v,
2027
- ...C
2028
- } = m, x = D({ created_at_ts: g, updated_at_ts: v }, [
2027
+ ...N
2028
+ } = m, T = D({ created_at_ts: g, updated_at_ts: v }, [
2029
2029
  "created_at_ts",
2030
2030
  "updated_at_ts"
2031
2031
  ]);
2032
2032
  return y({
2033
- ...C,
2034
- ...x,
2033
+ ...N,
2034
+ ...T,
2035
2035
  enabled: !!p,
2036
2036
  synchronous: !!f
2037
2037
  });
@@ -2325,7 +2325,7 @@ function cn(e) {
2325
2325
  updated_at_ts: Date.now(),
2326
2326
  // Only update expires_at_ts if a new expires_at was provided
2327
2327
  // Use !== undefined to preserve null values (which mean "doesn't expire")
2328
- ...s !== void 0 ? { expires_at_ts: N(s) } : {}
2328
+ ...s !== void 0 ? { expires_at_ts: C(s) } : {}
2329
2329
  }).where("login_sessions.id", "=", a).where("login_sessions.tenant_id", "=", t).execute()).length === 1;
2330
2330
  };
2331
2331
  }
@@ -2488,7 +2488,7 @@ function vn(e) {
2488
2488
  resource_servers: d,
2489
2489
  rotating: c,
2490
2490
  ...l
2491
- } = a, m = Date.now(), _ = N(r), p = s ? N(s) : null, f = Math.max(
2491
+ } = a, m = Date.now(), _ = C(r), p = s ? C(s) : null, f = Math.max(
2492
2492
  _ ?? 0,
2493
2493
  p ?? 0
2494
2494
  );
@@ -2502,7 +2502,7 @@ function vn(e) {
2502
2502
  created_at_ts: m,
2503
2503
  expires_at_ts: _,
2504
2504
  idle_expires_at_ts: p,
2505
- last_exchanged_at_ts: i ? N(i) : null
2505
+ last_exchanged_at_ts: i ? C(i) : null
2506
2506
  }).execute(), f > 0 && a.login_id && await g.updateTable("login_sessions").set({
2507
2507
  expires_at_ts: f,
2508
2508
  updated_at_ts: m
@@ -2515,51 +2515,39 @@ function Cn(e) {
2515
2515
  }
2516
2516
  function xn(e) {
2517
2517
  return async (t, a, n) => {
2518
- const o = N(n), r = await e.updateTable("refresh_tokens").set({ revoked_at_ts: o }).where("tenant_id", "=", t).where("login_id", "=", a).where("revoked_at_ts", "is", null).executeTakeFirst();
2518
+ const o = C(n), r = await e.updateTable("refresh_tokens").set({ revoked_at_ts: o }).where("tenant_id", "=", t).where("login_id", "=", a).where("revoked_at_ts", "is", null).executeTakeFirst();
2519
2519
  return Number(r.numUpdatedRows ?? 0);
2520
2520
  };
2521
2521
  }
2522
2522
  function Tn(e) {
2523
- return async (t, a, n) => {
2523
+ return async (t, a, n, o) => {
2524
2524
  const {
2525
- created_at: o,
2526
- expires_at: r,
2527
- idle_expires_at: s,
2528
- last_exchanged_at: i,
2529
- revoked_at: u,
2530
- device: d,
2531
- resource_servers: c,
2532
- rotating: l,
2533
- ...m
2534
- } = n, _ = {
2535
- ...m,
2536
- device: d ? JSON.stringify(d) : void 0,
2537
- resource_servers: c ? JSON.stringify(c) : void 0,
2538
- rotating: l !== void 0 ? l ? 1 : 0 : void 0,
2525
+ created_at: r,
2526
+ expires_at: s,
2527
+ idle_expires_at: i,
2528
+ last_exchanged_at: u,
2529
+ revoked_at: d,
2530
+ device: c,
2531
+ resource_servers: l,
2532
+ rotating: m,
2533
+ ..._
2534
+ } = n, p = {
2535
+ ..._,
2536
+ device: c ? JSON.stringify(c) : void 0,
2537
+ resource_servers: l ? JSON.stringify(l) : void 0,
2538
+ rotating: m !== void 0 ? m ? 1 : 0 : void 0,
2539
2539
  // Convert date fields to bigint format
2540
2540
  // Use !== undefined to preserve null values (which mean "doesn't expire")
2541
- expires_at_ts: r !== void 0 ? N(r) : void 0,
2542
- idle_expires_at_ts: s !== void 0 ? N(s) : void 0,
2543
- last_exchanged_at_ts: i !== void 0 ? N(i) : void 0,
2544
- revoked_at_ts: u !== void 0 ? N(u) : void 0
2545
- };
2546
- return e.transaction().execute(async (p) => {
2547
- const g = !!(await p.updateTable("refresh_tokens").set(_).where("tenant_id", "=", t).where("refresh_tokens.id", "=", a).execute()).length, v = _.expires_at_ts !== void 0 || _.idle_expires_at_ts !== void 0;
2548
- if (g && v) {
2549
- const C = await p.selectFrom("refresh_tokens").select(["login_id", "expires_at_ts", "idle_expires_at_ts"]).where("tenant_id", "=", t).where("refresh_tokens.id", "=", a).executeTakeFirst();
2550
- if (C != null && C.login_id) {
2551
- const x = Math.max(
2552
- C.expires_at_ts ?? 0,
2553
- C.idle_expires_at_ts ?? 0
2554
- );
2555
- x > 0 && await p.updateTable("login_sessions").set({
2556
- expires_at_ts: x,
2557
- updated_at_ts: Date.now()
2558
- }).where("tenant_id", "=", t).where("id", "=", C.login_id).where("expires_at_ts", "<", x).execute();
2559
- }
2560
- }
2561
- return g;
2562
- });
2541
+ expires_at_ts: s !== void 0 ? C(s) : void 0,
2542
+ idle_expires_at_ts: i !== void 0 ? C(i) : void 0,
2543
+ last_exchanged_at_ts: u !== void 0 ? C(u) : void 0,
2544
+ revoked_at_ts: d !== void 0 ? C(d) : void 0
2545
+ }, f = o == null ? void 0 : o.loginSessionBump, g = f ? C(f.expires_at) : null, v = await e.updateTable("refresh_tokens").set(p).where("tenant_id", "=", t).where("refresh_tokens.id", "=", a).executeTakeFirst();
2546
+ return f != null && f.login_id && g && g > 0 && await e.updateTable("login_sessions").set({
2547
+ expires_at_ts: g,
2548
+ updated_at_ts: Date.now()
2549
+ }).where("tenant_id", "=", t).where("id", "=", f.login_id).where("expires_at_ts", "<", g).execute().catch(() => {
2550
+ }), ((v == null ? void 0 : v.numUpdatedRows) ?? 0n) > 0n;
2563
2551
  };
2564
2552
  }
2565
2553
  function Nn(e) {
@@ -2578,16 +2566,16 @@ function Nn(e) {
2578
2566
  tenant_id: f,
2579
2567
  created_at_ts: g,
2580
2568
  expires_at_ts: v,
2581
- idle_expires_at_ts: C,
2582
- last_exchanged_at_ts: x,
2569
+ idle_expires_at_ts: N,
2570
+ last_exchanged_at_ts: T,
2583
2571
  revoked_at_ts: b,
2584
2572
  ...I
2585
- } = p, T = D(
2573
+ } = p, x = D(
2586
2574
  {
2587
2575
  created_at_ts: g,
2588
2576
  expires_at_ts: v,
2589
- idle_expires_at_ts: C,
2590
- last_exchanged_at_ts: x,
2577
+ idle_expires_at_ts: N,
2578
+ last_exchanged_at_ts: T,
2591
2579
  revoked_at_ts: b
2592
2580
  },
2593
2581
  ["created_at_ts"],
@@ -2600,7 +2588,7 @@ function Nn(e) {
2600
2588
  );
2601
2589
  return {
2602
2590
  ...I,
2603
- ...T,
2591
+ ...x,
2604
2592
  rotating: !!p.rotating,
2605
2593
  device: p.device ? JSON.parse(p.device) : {},
2606
2594
  resource_servers: p.resource_servers ? JSON.parse(p.resource_servers) : []
@@ -2866,8 +2854,8 @@ function Fn(e) {
2866
2854
  if (s) {
2867
2855
  const m = s.trim(), _ = m.split(/\s+/), p = _.length === 1 ? _[0] : void 0, f = p ? p.match(/^(-)?(name|identifier):(.*)$/) : null, g = f ? f[3] : "", v = /^(>=|>|<=|<)/.test(g || "");
2868
2856
  if (f && !v) {
2869
- const C = !!f[1], x = f[2] === "name" ? "resource_servers.name" : "resource_servers.identifier";
2870
- i = C ? i.where(x, "not like", `%${g}%`) : i.where(x, "like", `%${g}%`);
2857
+ const N = !!f[1], T = f[2] === "name" ? "resource_servers.name" : "resource_servers.identifier";
2858
+ i = N ? i.where(T, "not like", `%${g}%`) : i.where(T, "like", `%${g}%`);
2871
2859
  } else
2872
2860
  i = $(e, i, m, [
2873
2861
  "resource_servers.name",
@@ -2880,22 +2868,22 @@ function Fn(e) {
2880
2868
  scopes: f,
2881
2869
  options: g,
2882
2870
  skip_consent_for_verifiable_first_party_clients: v,
2883
- allow_offline_access: C,
2884
- is_system: x,
2871
+ allow_offline_access: N,
2872
+ is_system: T,
2885
2873
  metadata: b,
2886
2874
  ...I
2887
- } = _, T = y({
2875
+ } = _, x = y({
2888
2876
  ...I,
2889
2877
  scopes: f ? JSON.parse(f) : [],
2890
2878
  options: g ? JSON.parse(g) : {},
2891
2879
  skip_consent_for_verifiable_first_party_clients: !!v,
2892
- allow_offline_access: !!C,
2893
- is_system: x ? !0 : void 0,
2880
+ allow_offline_access: !!N,
2881
+ is_system: T ? !0 : void 0,
2894
2882
  metadata: b ? JSON.parse(b) : void 0,
2895
2883
  // Convert verification_key back to verificationKey for API
2896
2884
  verificationKey: p
2897
2885
  });
2898
- return T.token_lifetime ?? (T.token_lifetime = 86400), T.token_lifetime_for_web ?? (T.token_lifetime_for_web = 7200), T;
2886
+ return x.token_lifetime ?? (x.token_lifetime = 86400), x.token_lifetime_for_web ?? (x.token_lifetime_for_web = 7200), x;
2899
2887
  });
2900
2888
  if (!r)
2901
2889
  return {