@absolutejs/auth 0.47.0 → 0.48.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/index.js CHANGED
@@ -9605,6 +9605,22 @@ var performStoreCleanup = async ({
9605
9605
  onSessionCleanup
9606
9606
  }) => {
9607
9607
  const now = Date.now();
9608
+ if (authSessionStore.deleteExpired) {
9609
+ const removedSessionCount = await authSessionStore.deleteExpired();
9610
+ const removedUnregisteredCount = await authSessionStore.deleteExpiredUnregistered?.() ?? 0;
9611
+ if (removedSessionCount > 0 || removedUnregisteredCount > 0) {
9612
+ console.info(`[sessionCleanup] deleted expired sessions=${removedSessionCount} unregistered=${removedUnregisteredCount}`);
9613
+ }
9614
+ try {
9615
+ await onSessionCleanup?.({
9616
+ removedSessions: new Map,
9617
+ removedUnregisteredSessions: new Map
9618
+ });
9619
+ } catch (err) {
9620
+ console.error("[sessionCleanup] onSessionCleanup handler failed:", err);
9621
+ }
9622
+ return;
9623
+ }
9608
9624
  const sessionEntries = await loadStoreSessions(authSessionStore);
9609
9625
  const unregisteredEntries = await loadStoreUnregisteredSessions(authSessionStore);
9610
9626
  if (!sessionEntries || !unregisteredEntries) {
@@ -11652,6 +11668,19 @@ var ExtraConfigColumn = class extends PgColumn {
11652
11668
  return this;
11653
11669
  }
11654
11670
  };
11671
+ var IndexedColumn = class {
11672
+ static [entityKind] = "IndexedColumn";
11673
+ constructor(name2, keyAsName, type, indexConfig) {
11674
+ this.name = name2;
11675
+ this.keyAsName = keyAsName;
11676
+ this.type = type;
11677
+ this.indexConfig = indexConfig;
11678
+ }
11679
+ name;
11680
+ keyAsName;
11681
+ type;
11682
+ indexConfig;
11683
+ };
11655
11684
 
11656
11685
  // node_modules/drizzle-orm/pg-core/columns/int.common.js
11657
11686
  var PgIntColumnBuilder = class extends PgColumnBuilder {
@@ -13632,30 +13661,53 @@ var PrimaryKey = class {
13632
13661
  return this.name ?? `${this.table[PgTable.Symbol.Name]}_${this.columns.map((column) => column.name).join("_")}_pk`;
13633
13662
  }
13634
13663
  };
13635
- // node_modules/drizzle-orm/pg-core/checks.js
13636
- var CheckBuilder = class {
13637
- static [entityKind] = "PgCheckBuilder";
13638
- brand;
13639
- constructor(name2, value) {
13664
+ // node_modules/drizzle-orm/pg-core/indexes.js
13665
+ var IndexBuilderOn = class {
13666
+ static [entityKind] = "PgIndexBuilderOn";
13667
+ constructor(unique, name2) {
13668
+ this.unique = unique;
13640
13669
  this.name = name2;
13641
- this.value = value;
13642
- }
13643
- build(table) {
13644
- return new Check(table, this);
13645
13670
  }
13646
- };
13647
- var Check = class {
13648
- static [entityKind] = "PgCheck";
13649
- name;
13650
- value;
13651
- constructor(table, builder) {
13652
- this.table = table;
13653
- this.name = builder.name;
13654
- this.value = builder.value;
13671
+ on(...columns) {
13672
+ return new IndexBuilder(columns.map((it) => {
13673
+ if (is(it, SQL))
13674
+ return it;
13675
+ if (is(it, ExtraConfigColumn)) {
13676
+ const clonedIndexedColumn = new IndexedColumn(it.name, !!it.keyAsName, it.columnType, it.indexConfig);
13677
+ it.indexConfig = JSON.parse(JSON.stringify(it.defaultConfig));
13678
+ return clonedIndexedColumn;
13679
+ }
13680
+ it = it;
13681
+ return new IndexedColumn(it.name, !!it.keyAsName, it.columnType, {});
13682
+ }), this.unique, false, this.name);
13683
+ }
13684
+ onOnly(...columns) {
13685
+ return new IndexBuilder(columns.map((it) => {
13686
+ if (is(it, SQL))
13687
+ return it;
13688
+ if (is(it, ExtraConfigColumn)) {
13689
+ const clonedIndexedColumn = new IndexedColumn(it.name, !!it.keyAsName, it.columnType, it.indexConfig);
13690
+ it.indexConfig = JSON.parse(JSON.stringify(it.defaultConfig));
13691
+ return clonedIndexedColumn;
13692
+ }
13693
+ it = it;
13694
+ return new IndexedColumn(it.name, !!it.keyAsName, it.columnType, {});
13695
+ }), this.unique, true, this.name);
13696
+ }
13697
+ using(method, ...columns) {
13698
+ return new IndexBuilder(columns.map((it) => {
13699
+ if (is(it, SQL))
13700
+ return it;
13701
+ if (is(it, ExtraConfigColumn)) {
13702
+ const clonedIndexedColumn = new IndexedColumn(it.name, !!it.keyAsName, it.columnType, it.indexConfig);
13703
+ it.indexConfig = JSON.parse(JSON.stringify(it.defaultConfig));
13704
+ return clonedIndexedColumn;
13705
+ }
13706
+ it = it;
13707
+ return new IndexedColumn(it.name, !!it.keyAsName, it.columnType, {});
13708
+ }), this.unique, true, this.name, method);
13655
13709
  }
13656
13710
  };
13657
-
13658
- // node_modules/drizzle-orm/pg-core/indexes.js
13659
13711
  var IndexBuilder = class {
13660
13712
  static [entityKind] = "PgIndexBuilder";
13661
13713
  config;
@@ -13696,6 +13748,31 @@ var Index = class {
13696
13748
  this.isNameExplicit = !!config.name;
13697
13749
  }
13698
13750
  };
13751
+ function index(name2) {
13752
+ return new IndexBuilderOn(false, name2);
13753
+ }
13754
+ // node_modules/drizzle-orm/pg-core/checks.js
13755
+ var CheckBuilder = class {
13756
+ static [entityKind] = "PgCheckBuilder";
13757
+ brand;
13758
+ constructor(name2, value) {
13759
+ this.name = name2;
13760
+ this.value = value;
13761
+ }
13762
+ build(table) {
13763
+ return new Check(table, this);
13764
+ }
13765
+ };
13766
+ var Check = class {
13767
+ static [entityKind] = "PgCheck";
13768
+ name;
13769
+ value;
13770
+ constructor(table, builder) {
13771
+ this.table = table;
13772
+ this.name = builder.name;
13773
+ this.value = builder.value;
13774
+ }
13775
+ };
13699
13776
 
13700
13777
  // node_modules/drizzle-orm/pg-core/policies.js
13701
13778
  var PgPolicy = class {
@@ -21565,7 +21642,7 @@ var authSessionsTable = pgTable("auth_sessions", {
21565
21642
  refresh_token: text("refresh_token"),
21566
21643
  updated_at: timestamp("updated_at").notNull().defaultNow(),
21567
21644
  user_json: jsonb("user_json").$type().notNull()
21568
- });
21645
+ }, (table) => [index("auth_sessions_expires_at_idx").on(table.expires_at_ms)]);
21569
21646
  var authUnregisteredSessionsTable = pgTable("auth_unregistered_sessions", {
21570
21647
  access_token: text("access_token"),
21571
21648
  created_at: timestamp("created_at").notNull().defaultNow(),
@@ -21575,7 +21652,9 @@ var authUnregisteredSessionsTable = pgTable("auth_unregistered_sessions", {
21575
21652
  session_information_json: jsonb("session_information_json").$type(),
21576
21653
  updated_at: timestamp("updated_at").notNull().defaultNow(),
21577
21654
  user_identity_json: jsonb("user_identity_json").$type()
21578
- });
21655
+ }, (table) => [
21656
+ index("auth_unregistered_sessions_expires_at_idx").on(table.expires_at_ms)
21657
+ ]);
21579
21658
  var cloneUser = (value) => {
21580
21659
  if (value === null || value === undefined)
21581
21660
  return value;
@@ -21616,6 +21695,14 @@ var createNeonAuthSessionStore = (databaseUrl) => {
21616
21695
  const rows = await db.select({ id: authUnregisteredSessionsTable.id }).from(authUnregisteredSessionsTable);
21617
21696
  return rows.map((row) => row.id).filter(isUserSessionId);
21618
21697
  },
21698
+ deleteExpired: async () => {
21699
+ const rows = await db.delete(authSessionsTable).where(lt(authSessionsTable.expires_at_ms, Date.now())).returning({ id: authSessionsTable.id });
21700
+ return rows.length;
21701
+ },
21702
+ deleteExpiredUnregistered: async () => {
21703
+ const rows = await db.delete(authUnregisteredSessionsTable).where(lt(authUnregisteredSessionsTable.expires_at_ms, Date.now())).returning({ id: authUnregisteredSessionsTable.id });
21704
+ return rows.length;
21705
+ },
21619
21706
  removeSession: async (id) => {
21620
21707
  await db.delete(authSessionsTable).where(eq(authSessionsTable.id, id));
21621
21708
  },
@@ -27445,5 +27532,5 @@ export {
27445
27532
  AuthIdentityConflictError
27446
27533
  };
27447
27534
 
27448
- //# debugId=AEEC1560A2CA950D64756E2164756E21
27535
+ //# debugId=8F2A5FC27669AFAA64756E2164756E21
27449
27536
  //# sourceMappingURL=index.js.map