@smplcty/auth 4.0.0 → 5.0.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/README.md CHANGED
@@ -473,7 +473,7 @@ The library ships its schema as schema-flow YAML inside the package at `@smplcty
473
473
 
474
474
  ### Consuming with [`@smplcty/schema-flow`](https://www.npmjs.com/package/@smplcty/schema-flow)
475
475
 
476
- Requires **`@smplcty/schema-flow >= 0.12.0`** — the shipped seeds assign no primary keys (the app-init user and the standard roles are matched by their natural keys, `name`/`kind`), which earlier versions don't fully support.
476
+ Requires **`@smplcty/schema-flow >= 0.13.0`** — the shipped seeds assign no primary keys (the app-init user and the standard roles are matched by their natural keys, `name`/`kind`) and rely on insert-only seeding, where an existing row is never overwritten. `0.13.0` makes insert-only the default (the old per-table `seeds_on_conflict` knob is gone); on older versions these seeds would upsert and clobber any consumer edits to the standard roles on every migration.
477
477
 
478
478
  Import auth's schema and `@smplcty/schema-std` from your schema-flow config. See the reference [`schema-flow.config.yaml`](schema-flow.config.yaml):
479
479
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smplcty/auth",
3
- "version": "4.0.0",
3
+ "version": "5.0.0",
4
4
  "description": "Robust, type-safe session and role-based authentication primitives for PostgreSQL apps using Row-Level Security.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -105,7 +105,7 @@
105
105
  "devDependencies": {
106
106
  "@eslint/js": "^10.0.1",
107
107
  "@release-it/keep-a-changelog": "^7.1.0",
108
- "@smplcty/schema-flow": "^0.12.0",
108
+ "@smplcty/schema-flow": "^0.13.0",
109
109
  "@smplcty/twilio": "^0.1.1",
110
110
  "@testcontainers/postgresql": "^12.0.2",
111
111
  "@types/node": "^25.9.3",
@@ -13,3 +13,17 @@ indexes:
13
13
  unique: true
14
14
  where: 'deleted_at IS NULL'
15
15
  name: communication_channels_name_key
16
+ # The two channels @smplcty/auth ships out of the box. The library resolves a
17
+ # channel by name, never by id — the OIDC handler matches users on 'email',
18
+ # and the Twilio method router's default resolver maps an identifier to
19
+ # 'email' or 'phone' (see methods/twilio). No ids are pinned: the seeds carry
20
+ # no communication_channel_id, so schema-flow matches them by `name` (the
21
+ # partial-unique index backstops any duplicate). Consumers add their own
22
+ # channels by name.
23
+ #
24
+ # Seeds are insert-only (schema-flow >= 0.13.0 never overwrites an existing
25
+ # row), so re-running this migration against an already-seeded database is a
26
+ # no-op.
27
+ seeds:
28
+ - name: 'email'
29
+ - name: 'phone'
@@ -41,8 +41,9 @@ indexes:
41
41
  # duplicate). Consumers add their own roles by name; there are no reserved
42
42
  # id ranges to avoid.
43
43
  #
44
- # seeds_on_conflict: DO NOTHING, so re-running this migration against an
45
- # already-seeded database is a no-op.
44
+ # Seeds are insert-only (schema-flow >= 0.13.0 never overwrites an existing
45
+ # row), so re-running this migration against an already-seeded database is a
46
+ # no-op — and a consumer's edits to these standard roles are never clobbered.
46
47
  seeds:
47
48
  - name: 'user'
48
49
  display_name: 'User'
@@ -59,4 +60,3 @@ seeds:
59
60
  description: 'Security administration.'
60
61
  is_default: false
61
62
  is_privilege: false
62
- seeds_on_conflict: 'DO NOTHING'
@@ -21,6 +21,18 @@ columns:
21
21
  nullable: false
22
22
  default: "'human'"
23
23
  check: "kind IN ('human', 'service')"
24
+ indexes:
25
+ # Service users are principals resolved by name (audit_backfill_by looks up
26
+ # WHERE name = … AND kind = 'service'; see withServiceContext), so two live
27
+ # service rows sharing a name would make that lookup ambiguous. Enforce
28
+ # uniqueness of the name among live service users only. Humans are NOT
29
+ # constrained — real people legitimately share names and are referenced by
30
+ # id, never by name. Partial on deleted_at so a name frees up after the row
31
+ # is soft-deleted.
32
+ - columns: [name]
33
+ unique: true
34
+ where: "kind = 'service' AND deleted_at IS NULL"
35
+ name: users_service_name_key
24
36
  # The bootstrap principal: the app-init service user. It's the actor every
25
37
  # migration-time seed (this row, the standard roles, any consumer seeds) is
26
38
  # attributed to via app.actor_id, resolved by name — `audit_backfill_by`
@@ -28,8 +40,8 @@ columns:
28
40
  # fixed id. It seeds first (users seed before tables that FK to it) and stamps
29
41
  # its own created_by (the self-reference resolves because the row exists by the
30
42
  # time the FK is checked). No id is pinned: the seed has no primary key, so
31
- # schema-flow matches it on (name, kind) and re-runs are a no-op.
43
+ # schema-flow matches it on (name, kind). Seeds are insert-only (schema-flow
44
+ # >= 0.13.0 never overwrites an existing row), so re-runs are a no-op.
32
45
  seeds:
33
46
  - name: 'app-init'
34
47
  kind: 'service'
35
- seeds_on_conflict: 'DO NOTHING'