@absolutejs/auth 0.79.0 → 0.80.1

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/CHANGELOG.md CHANGED
@@ -6,6 +6,22 @@ This file is generated by `absolute-changelog` from the entries in
6
6
  `changelog/`. Edit an entry, not this file — and add new ones under
7
7
  `changelog/unreleased/`.
8
8
 
9
+ ## 0.80.1 — 2026-09-22
10
+
11
+ ### Fixed
12
+
13
+ - **Document verified persistent credentials integration and correct Drizzle and migration APIs**
14
+
15
+ ## 0.80.0 — 2026-09-22
16
+
17
+ ### Added
18
+
19
+ - **Support existing Drizzle PostgreSQL clients for durable auth sessions** (`createPostgresAuthSessionStore`)
20
+
21
+ ### Fixed
22
+
23
+ - **Run auth setup according to the selected session store instead of always requiring PostgreSQL**
24
+
9
25
  ## 0.79.0 — 2026-09-10
10
26
 
11
27
  ### Breaking
package/README.md CHANGED
@@ -408,3 +408,37 @@ Prefer configuring both features in `auth({ oidc, apikeys })`: conflicting token
408
408
  paths are rejected during construction, including a trailing-slash alias.
409
409
  When mounting standalone plugins with custom paths, the consumer must keep
410
410
  the paths distinct; Elysia does not reject arbitrary duplicate routes.
411
+
412
+ ### Persistent sessions with an existing PostgreSQL client
413
+
414
+ Use `createPostgresAuthSessionStore(db, decodeUser)` with an existing Drizzle
415
+ PostgreSQL client. It uses the same session tables as the Neon convenience
416
+ adapter; `decodeUser` validates the stored user shape when a session is read.
417
+ Pair it with `createPostgresCredentialStore(db)` for persistent passwords.
418
+ Your application must also persist its own user records.
419
+
420
+ ```ts
421
+ import { SQL } from 'bun';
422
+ import { drizzle } from 'drizzle-orm/bun-sql';
423
+ import { createPostgresAuthSessionStore, createPostgresCredentialStore } from '@absolutejs/auth';
424
+
425
+ const databaseUrl = process.env.DATABASE_URL;
426
+ if (!databaseUrl) throw new Error('DATABASE_URL is required');
427
+ const client = new SQL(databaseUrl);
428
+ const db = drizzle({ client });
429
+ const sessionStore = createPostgresAuthSessionStore(db, decodeUser);
430
+ const credentialStore = createPostgresCredentialStore(db);
431
+ ```
432
+
433
+ Apply the `sessions` and `credentials` migrations before serving requests.
434
+ `runMigrations` accepts a `MigrationClient` for non-Neon PostgreSQL drivers.
435
+ With Bun SQL, use a separate `prepare: false` client for migration scripts,
436
+ and the default prepared-query mode for application queries and JSON columns.
437
+
438
+ Studio's `absolute-auth setup` reads the selected adapter from
439
+ `src/backend/packages/auth.config.ts`. Explicit memory storage skips database
440
+ migrations and warns that sessions reset on restart. The Neon adapter requires
441
+ a real `DATABASE_URL` and runs migrations. Missing or unknown selections fail
442
+ with an actionable error; custom adapters must configure their own migrations.
443
+
444
+ For a complete credentials-only Bun setup, see [Persistent email/password sign-in](docs/PERSISTENT-CREDENTIALS.md). It includes real migration and auth configuration APIs, durable user records, and driver settings.
package/changelog.json CHANGED
@@ -2,6 +2,33 @@
2
2
  "contract": 1,
3
3
  "name": "@absolutejs/auth",
4
4
  "releases": [
5
+ {
6
+ "changes": [
7
+ {
8
+ "kind": "fixed",
9
+ "summary": "Document verified persistent credentials integration and correct Drizzle and migration APIs"
10
+ }
11
+ ],
12
+ "date": "2026-09-22",
13
+ "version": "0.80.1"
14
+ },
15
+ {
16
+ "changes": [
17
+ {
18
+ "kind": "fixed",
19
+ "summary": "Run auth setup according to the selected session store instead of always requiring PostgreSQL"
20
+ },
21
+ {
22
+ "kind": "added",
23
+ "summary": "Support existing Drizzle PostgreSQL clients for durable auth sessions",
24
+ "symbols": [
25
+ "createPostgresAuthSessionStore"
26
+ ]
27
+ }
28
+ ],
29
+ "date": "2026-09-22",
30
+ "version": "0.80.0"
31
+ },
5
32
  {
6
33
  "changes": [
7
34
  {
@@ -289,6 +289,10 @@ var runImport = async (result, options) => {
289
289
  };
290
290
  };
291
291
 
292
+ // src/cli/setup.ts
293
+ import { resolve } from "path";
294
+ import { pathToFileURL } from "url";
295
+
292
296
  // src/adaptive/postgresStores.ts
293
297
  import { and, desc, eq } from "drizzle-orm";
294
298
  import {
@@ -3473,11 +3477,46 @@ var blockMigrations = {
3473
3477
  webhooks: initMigration("webhooks", [webhookDeliveriesTable])
3474
3478
  };
3475
3479
 
3480
+ // src/cli/setup.ts
3481
+ var readProperty = (value, key) => {
3482
+ const property = typeof value === "object" && value !== null ? Reflect.get(value, key) : undefined;
3483
+ return property;
3484
+ };
3485
+ var setupStorage = (configuration) => {
3486
+ const selected = readProperty(readProperty(configuration, "adapters"), "sessionStore");
3487
+ if (selected === "@absolutejs/auth#createInMemoryAuthSessionStore")
3488
+ return "memory";
3489
+ if (selected === "@absolutejs/auth#createNeonAuthSessionStore")
3490
+ return "neon";
3491
+ throw new Error("Select a supported auth sessionStore adapter in src/backend/packages/auth.config.ts before setup. Custom adapters need their own migrations.");
3492
+ };
3493
+ var loadConfiguration = async () => {
3494
+ const module = await import(pathToFileURL(resolve("src/backend/packages/auth.config.ts")).href);
3495
+ return readProperty(module, "default");
3496
+ };
3497
+ var runSetup = async ({
3498
+ configuration,
3499
+ databaseUrl = process.env["DATABASE_URL"],
3500
+ migrate = runMigrations,
3501
+ log = console.log
3502
+ } = {}) => {
3503
+ const storage = setupStorage(configuration ?? await loadConfiguration());
3504
+ if (storage === "memory") {
3505
+ log("In-memory sessions selected: no database migration is needed. Sign-ins reset on restart; choose persistent storage for a live business.");
3506
+ return { migrated: false, storage };
3507
+ }
3508
+ if (!databaseUrl?.trim())
3509
+ throw new Error("The selected Neon session store requires DATABASE_URL. Configure a real Neon database connection; do not enter a placeholder.");
3510
+ await migrate({ databaseUrl, log });
3511
+ return { migrated: true, storage };
3512
+ };
3513
+
3476
3514
  // src/cli/migrate.ts
3477
3515
  var TOP_USAGE = `Usage:
3478
3516
  bunx absolute-auth <command> [options]
3479
3517
 
3480
3518
  Commands:
3519
+ setup Set up storage selected in the project auth config
3481
3520
  migrate Apply the package's Drizzle migrations
3482
3521
  import <source> <file> Import a user export from another auth library
3483
3522
  <source> is one of: ${Object.keys(importers).sort().join(", ")}
@@ -3647,6 +3686,12 @@ var main = async () => {
3647
3686
  process.stdout.write(TOP_USAGE);
3648
3687
  return;
3649
3688
  }
3689
+ if (command === "setup") {
3690
+ if (argv.length > 0)
3691
+ throw new Error("setup takes no arguments; it reads src/backend/packages/auth.config.ts");
3692
+ await runSetup();
3693
+ return;
3694
+ }
3650
3695
  if (command === "migrate") {
3651
3696
  await runMigrate(argv);
3652
3697
  return;
@@ -3659,5 +3704,5 @@ var main = async () => {
3659
3704
  };
3660
3705
  await main();
3661
3706
 
3662
- //# debugId=1171B72D10FC06DD64756E2164756E21
3707
+ //# debugId=049EB7FB9B6E388E64756E2164756E21
3663
3708
  //# sourceMappingURL=migrate.js.map