@happyvertical/smrt-users 0.57.12 → 0.57.14

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/AGENTS.md CHANGED
@@ -99,7 +99,12 @@ are not prerequisites for unrelated user-package work.
99
99
  `setPin` ends that session; do not grant it authority another way.
100
100
  - `UsersPasswordCredential` is one row per person, sensitive, with no
101
101
  generated surface; `PasswordCredentialService` and its handlers are its only
102
- read/write paths. Sign-in normalizes the email like `emailKey`, reserves
102
+ session-authorized read/write paths. The separate Node `./operator` entrypoint
103
+ provisions new PostgreSQL owners from trusted database custody, atomically;
104
+ never mount it in a browser/REST/MCP handler. Exact retries verify existing
105
+ credentials without writes; partial/conflicting identities fail closed.
106
+ See README "Trusted deployment owner provisioning".
107
+ Sign-in normalizes the email like `emailKey`, reserves
103
108
  before work, always runs one scrypt verify (dummy hash when absent), never
104
109
  creates a user, and maps every non-rate-limit refusal to one
105
110
  `PasswordCredentialError`. It re-checks the credential after the mint (a
package/README.md CHANGED
@@ -904,6 +904,14 @@ Other credential kinds (a fob or badge reader, say) implement
904
904
 
905
905
  ### Password sign-in
906
906
 
907
+ For a self-hosted public password deployment, set
908
+ `SMRT_AUTH_READINESS_MODULE=@happyvertical/smrt-users`. The existing
909
+ app-runtime provider-readiness factory then opens the configured PostgreSQL
910
+ database and requires the password, session, membership, and login-limiter
911
+ schema used by `PasswordCredentialService`; it never creates schema. Browser
912
+ owner bootstrap remains local-only, so production owners are provisioned by a
913
+ separate operator path.
914
+
907
915
  `PasswordCredentialService` (#3274) gives an app without an identity provider
908
916
  email-or-username + password sign-in for **existing, active** users. It never creates a
909
917
  user. The password lives in its own object, `UsersPasswordCredential`
@@ -1092,6 +1100,57 @@ What the app must do:
1092
1100
 
1093
1101
  Passkeys/WebAuthn are a separate credential (#3275).
1094
1102
 
1103
+ ### Trusted deployment owner provisioning
1104
+
1105
+ Self-hosted password deployments keep browser owner bootstrap disabled. After
1106
+ building the app, run migrations and provision the owner from a trusted operator
1107
+ shell using the compiled registration entry. These commands need Node and the
1108
+ published packages, without a Vite runtime:
1109
+
1110
+ ```sh
1111
+ node --import ./.smrt/runtime/register.js node_modules/@happyvertical/smrt-cli/bin/smrt.js db:migrate
1112
+ node --import ./.smrt/runtime/register.js node_modules/@happyvertical/smrt-cli/bin/smrt.js users:provision-owner \
1113
+ --tenant-id 2acb0135-6d63-40dc-a8d4-fd87d37cd197 --tenant-name Hearth \
1114
+ --user-id 753d9480-fd17-4f21-8771-345e83833fe3 \
1115
+ --email owner@example.com --username owner --password-stdin < /run/secrets/owner-password
1116
+ ```
1117
+
1118
+ Use your own stable UUIDs and identities; retain them for retries. The database
1119
+ comes from normal CLI configuration (`packages.cli.database`, or `DATABASE_URL`
1120
+ and `DATABASE_TYPE=postgres`). Supply at least one email or username. The password
1121
+ must be one UTF-8 line; a final newline is removed. `--password-file` also accepts
1122
+ a regular mode-0400/0600 file (no final symlink); stdin redirection works with
1123
+ mounted secret symlinks. Password arguments and environment inputs are unsupported.
1124
+
1125
+ The Node-only `@happyvertical/smrt-users/operator` export provides
1126
+ `provisionPasswordOwner(db, input, passwordPolicy?)` for operator tools that use
1127
+ the application's custom password policy or pepper. The CLI uses the ordinary
1128
+ default policy. Never expose this function through browser, REST, MCP, or
1129
+ session handlers: possession of the database connection is its authority.
1130
+
1131
+ Provisioning supports PostgreSQL only. It creates the tenant, User, owner
1132
+ membership, and ordinary password credential in one transaction, without minting
1133
+ a session. A fresh authority catalog receives the standard roles and grants;
1134
+ existing role grants are never reseeded. Both creation and exact retries require
1135
+ at least one effective permission, resolved with tenant and membership DENY
1136
+ overrides inside that transaction. Existing restricted roles remain restricted;
1137
+ success does not promise every application permission. An empty or fully denied
1138
+ permission set refuses with the ordinary sanitized error and CLI exit status 1,
1139
+ rolling back new identities and leaving existing credentials and grants intact.
1140
+ If roles were initialized without grants, inspect the intended authority policy
1141
+ and explicitly seed approved grants using `RoleCollection.seedSystemRoles({
1142
+ seedPermissions: true })` from a trusted operator tool, or administer the desired
1143
+ restricted grants through the public role services, before retrying. Provisioning
1144
+ never restores deliberately revoked grants automatically.
1145
+
1146
+ An existing target tenant must be an
1147
+ active root tenant with the exact name and no memberships. Existing or partial
1148
+ User identities are refused except for a complete exact retry with the same
1149
+ active owner membership and password, which returns `unchanged` without writes.
1150
+ It never resets a password, reactivates an account, or adopts an ambiguous
1151
+ identity. After provisioning, the owner signs in using the normal password
1152
+ route. Local loopback bootstrap remains unchanged.
1153
+
1095
1154
  ### Request-scoped database access
1096
1155
 
1097
1156
  Generated SvelteKit helpers and custom server code can read the current