@smplcty/auth 3.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
@@ -371,8 +371,8 @@ console.log(await qrcode.toString(uri, { type: 'terminal', small: true }));
371
371
  console.log(`\nManual entry secret: ${secret}\n`);
372
372
  console.log('After scanning, run this SQL against your database:');
373
373
  console.log(`
374
- INSERT INTO dev_otp_enrollments (user_communication_method_id, totp_secret, label)
375
- SELECT ucm.user_communication_method_id, '${secret}', '${label.replace(/'/g, "''")}'
374
+ INSERT INTO dev_otp_enrollments (user_communication_method_id, totp_secret)
375
+ SELECT ucm.user_communication_method_id, '${secret}'
376
376
  FROM user_communication_methods ucm
377
377
  JOIN communication_channels cc ON cc.communication_channel_id = ucm.communication_channel_id
378
378
  WHERE cc.name = 'phone' AND ucm.code = '${phone}';
@@ -455,12 +455,12 @@ The library ships its schema as schema-flow YAML inside the package at `@smplcty
455
455
  ```
456
456
  @smplcty/auth/schema/
457
457
  ├── tables/
458
- │ ├── users.yaml # + audit; seeds the app-init service user (id 1)
458
+ │ ├── users.yaml # + audit; seeds the app-init service user (matched by name)
459
459
  │ ├── tenants.yaml # + audit; slug (sub-domain), allow_otp (SSO-only switch)
460
460
  │ ├── roles.yaml # + audit; seeds 'user' (default), 'settings', 'security'
461
461
  │ ├── user_roles.yaml # + audit; tenant_id NULL = wildcard / all tenants
462
- │ ├── communication_channels.yaml
463
- │ ├── user_communication_methods.yaml
462
+ │ ├── communication_channels.yaml # + audit
463
+ │ ├── user_communication_methods.yaml # + audit
464
464
  │ ├── auth_domains.yaml # + audit; tenant's IdP(s), 1:N, resolved by id (display_name = button)
465
465
  │ ├── sessions.yaml # PK = token hash; last_seen_at; geo
466
466
  │ └── dev_otp_enrollments.yaml
@@ -473,6 +473,8 @@ 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.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
+
476
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):
477
479
 
478
480
  ```yaml
@@ -482,7 +484,7 @@ default:
482
484
  - package: '@smplcty/auth' # identity/tenant/auth_domains tables + resolve_session/current_user_id
483
485
  ```
484
486
 
485
- The `audit` mixin makes `created_by`/`updated_by` NOT NULL, stamped from `app.actor_id`. Rows seeded during migration have no request actor, so the shipped `post/` script back-fills them to the seeded `app-init` service user (`users.user_id = 1`) before the NOT NULL tighten phase — see the config for details.
487
+ The `audit` mixin makes `created_by`/`updated_by` NOT NULL, stamped from `app.actor_id`. Rows seeded during migration have no request actor, so the shipped `post/` script back-fills them to the seeded `app-init` service user (resolved by name, not a fixed id) before the NOT NULL tighten phase — see the config for details.
486
488
 
487
489
  ### Soft delete
488
490
 
@@ -1 +1 @@
1
- {"version":3,"file":"dev-otp.d.ts","sourceRoot":"","sources":["../src/dev-otp.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AA4C5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAsB,YAAY,CAAC,EAAE,EAAE,SAAS,EAAE,yBAAyB,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAiCnH;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,gBAAgB,CAAC,EAAE,EAAE,SAAS,EAAE,yBAAyB,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAMzG;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAE7C;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAevG"}
1
+ {"version":3,"file":"dev-otp.d.ts","sourceRoot":"","sources":["../src/dev-otp.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AA0C5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAsB,YAAY,CAAC,EAAE,EAAE,SAAS,EAAE,yBAAyB,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAiCnH;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,gBAAgB,CAAC,EAAE,EAAE,SAAS,EAAE,yBAAyB,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAMzG;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAE7C;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAevG"}
package/dist/dev-otp.js CHANGED
@@ -10,7 +10,6 @@ const SELECT_ENROLLMENT = `
10
10
  SELECT
11
11
  user_communication_method_id AS "userCommunicationMethodId",
12
12
  totp_secret AS "totpSecret",
13
- label AS "label",
14
13
  enrolled_at AS "enrolledAt",
15
14
  last_used_at AS "lastUsedAt",
16
15
  used_count AS "usedCount"
@@ -1 +1 @@
1
- {"version":3,"file":"dev-otp.js","sourceRoot":"","sources":["../src/dev-otp.ts"],"names":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,cAAc,EAAE,CAAC;AAC1B,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,sBAAsB,CAAC,KAAwD;IAC7F,IAAI,OAAO,KAAK,EAAE,MAAM,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACnE,MAAM,IAAI,iBAAiB,CAAC,mCAAmC,CAAC,CAAC;IACnE,CAAC;IACD,IAAI,OAAO,KAAK,EAAE,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACjE,MAAM,IAAI,iBAAiB,CAAC,kCAAkC,CAAC,CAAC;IAClE,CAAC;IACD,IAAI,OAAO,KAAK,EAAE,MAAM,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACnE,MAAM,IAAI,iBAAiB,CAAC,mCAAmC,CAAC,CAAC;IACnE,CAAC;IACD,OAAO,WAAW,CAAC;QACjB,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,MAAM,EAAE,KAAK,CAAC,MAAM;KACrB,CAAC,CAAC;AACL,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smplcty/auth",
3
- "version": "3.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.11.2",
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",
@@ -1,5 +1,5 @@
1
1
  table: communication_channels
2
- mixins: [soft_delete]
2
+ mixins: [audit, soft_delete]
3
3
  columns:
4
4
  - name: communication_channel_id
5
5
  type: bigserial
@@ -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'
@@ -18,12 +18,6 @@ columns:
18
18
  type: text
19
19
  nullable: false
20
20
 
21
- # Human label for the enrollment — useful when an admin needs to
22
- # know whose phone this is. Examples: "Sam's iPhone", "Mark's 1Password vault".
23
- - name: label
24
- type: text
25
- nullable: false
26
-
27
21
  - name: enrolled_at
28
22
  type: timestamptz
29
23
  nullable: false
@@ -34,32 +34,29 @@ indexes:
34
34
  unique: true
35
35
  where: 'deleted_at IS NULL'
36
36
  name: roles_name_key
37
- # The canonical role names shipped with @smplcty/auth. IDs 1-3 are
38
- # reserved for these standard mode roles. Consumers adding their own
39
- # roles (or privileges) should use IDs >= 100 to avoid colliding with
40
- # future standard-role additions. The library never references these IDs
41
- # directly — it always looks up by name — so the IDs are just a stable
42
- # convention for migration-time conflict detection.
37
+ # The canonical role names shipped with @smplcty/auth. The library never
38
+ # references roles by id — it always looks them up by name — so no ids are
39
+ # pinned here: the seeds carry no role_id, and schema-flow matches them by
40
+ # their natural columns (the partial-unique index on `name` backstops any
41
+ # duplicate). Consumers add their own roles by name; there are no reserved
42
+ # id ranges to avoid.
43
43
  #
44
- # Seeds use ON CONFLICT DO NOTHING via schema-flow, so re-running this
45
- # migration against an 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
- - role_id: 1
48
- name: 'user'
48
+ - name: 'user'
49
49
  display_name: 'User'
50
50
  description: 'Standard signed-in user.'
51
51
  is_default: true
52
52
  is_privilege: false
53
- - role_id: 2
54
- name: 'settings'
53
+ - name: 'settings'
55
54
  display_name: 'Settings'
56
55
  description: 'Account and organisation settings access.'
57
56
  is_default: false
58
57
  is_privilege: false
59
- - role_id: 3
60
- name: 'security'
58
+ - name: 'security'
61
59
  display_name: 'Security'
62
60
  description: 'Security administration.'
63
61
  is_default: false
64
62
  is_privilege: false
65
- seeds_on_conflict: 'DO NOTHING'
@@ -1,5 +1,5 @@
1
1
  table: user_communication_methods
2
- mixins: [soft_delete]
2
+ mixins: [audit, soft_delete]
3
3
  columns:
4
4
  - name: user_communication_method_id
5
5
  type: bigserial
@@ -21,14 +21,27 @@ columns:
21
21
  nullable: false
22
22
  default: "'human'"
23
23
  check: "kind IN ('human', 'service')"
24
- # The bootstrap principal. user_id=1 is the app-init service user: the actor
25
- # every migration-time seed (this row, the standard roles, any consumer seeds)
26
- # is attributed to via app.actor_id. It seeds first (users seed before tables
27
- # that FK to it), and stamps its own created_by=1 (the self-reference resolves
28
- # because the row exists by the time the FK is checked). Consumers add their
29
- # own users at user_id >= 2.
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
36
+ # The bootstrap principal: the app-init service user. It's the actor every
37
+ # migration-time seed (this row, the standard roles, any consumer seeds) is
38
+ # attributed to via app.actor_id, resolved by name — `audit_backfill_by`
39
+ # looks it up with `WHERE name = 'app-init' AND kind = 'service'`, never by a
40
+ # fixed id. It seeds first (users seed before tables that FK to it) and stamps
41
+ # its own created_by (the self-reference resolves because the row exists by the
42
+ # time the FK is checked). No id is pinned: the seed has no primary key, so
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.
30
45
  seeds:
31
- - user_id: 1
32
- name: 'app-init'
46
+ - name: 'app-init'
33
47
  kind: 'service'
34
- seeds_on_conflict: 'DO NOTHING'