@happyvertical/smrt-users 0.54.0 → 0.54.2

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.
Files changed (37) hide show
  1. package/AGENTS.md +16 -0
  2. package/README.md +129 -3
  3. package/dist/chunks/{TerminalAuthService-BfxG493c.js → TerminalAuthService-B2cazTEg.js} +833 -155
  4. package/dist/chunks/TerminalAuthService-B2cazTEg.js.map +1 -0
  5. package/dist/collections/PasswordCredentialCollection.d.ts +53 -0
  6. package/dist/collections/PasswordCredentialCollection.d.ts.map +1 -0
  7. package/dist/collections/SessionCollection.d.ts +7 -2
  8. package/dist/collections/SessionCollection.d.ts.map +1 -1
  9. package/dist/collections/index.d.ts +1 -0
  10. package/dist/collections/index.d.ts.map +1 -1
  11. package/dist/index.d.ts +3 -3
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +4 -4
  14. package/dist/index.js.map +1 -1
  15. package/dist/manifest.json +422 -1
  16. package/dist/models/PasswordCredential.d.ts +36 -0
  17. package/dist/models/PasswordCredential.d.ts.map +1 -0
  18. package/dist/models/index.d.ts +1 -0
  19. package/dist/models/index.d.ts.map +1 -1
  20. package/dist/services/DeviceCredentialService.d.ts.map +1 -1
  21. package/dist/services/PasswordCredentialService.d.ts +302 -0
  22. package/dist/services/PasswordCredentialService.d.ts.map +1 -0
  23. package/dist/services/SessionService.d.ts +3 -1
  24. package/dist/services/SessionService.d.ts.map +1 -1
  25. package/dist/services/credential-hash.d.ts +76 -0
  26. package/dist/services/credential-hash.d.ts.map +1 -0
  27. package/dist/services/index.d.ts +1 -0
  28. package/dist/services/index.d.ts.map +1 -1
  29. package/dist/smrt-knowledge.json +208 -8
  30. package/dist/sveltekit/index.d.ts +1 -0
  31. package/dist/sveltekit/index.d.ts.map +1 -1
  32. package/dist/sveltekit/password-handlers.d.ts +91 -0
  33. package/dist/sveltekit/password-handlers.d.ts.map +1 -0
  34. package/dist/sveltekit.js +237 -68
  35. package/dist/sveltekit.js.map +1 -1
  36. package/package.json +10 -10
  37. package/dist/chunks/TerminalAuthService-BfxG493c.js.map +0 -1
@@ -3,13 +3,13 @@
3
3
  "sensitiveFieldsExcluded": true,
4
4
  "generatedAt": "1970-01-01T00:00:00.000Z",
5
5
  "packageName": "@happyvertical/smrt-users",
6
- "packageVersion": "0.54.0",
6
+ "packageVersion": "0.54.2",
7
7
  "sourceManifestPath": "dist/manifest.json",
8
8
  "agentDocPath": "AGENTS.md",
9
9
  "sourceHashes": {
10
- "manifest": "240c2e24420c9e6df07c5c35ca18667c71ee4ee9955ce282c11a35fe17d37396",
11
- "packageJson": "7f47cda4f1c68140198bf399274fe77d9add2d5e928dc09e77649d1b156228af",
12
- "agents": "a0c6228ba98d46fc4bb2d39d6cc857c0a8a15571661169d2f8ffdbd9c1b0b966",
10
+ "manifest": "8a896a906ff31153f532bcd4b63effa16a8002a381495635128eb13521563e2f",
11
+ "packageJson": "86e268892e4102b813c7d03601409840206e5ff7c94917b6efabb7b4a4aea600",
12
+ "agents": "fa1b9005064b329b1d2387cd56307b92a79f2cd4ea951776e687f9850a428335",
13
13
  "moduleDoc:agents/permissions.md": "5f6c0afab7e1fd0887b0d29b5a5b5ab2635694207bade70145d3cbfdb62ba78c",
14
14
  "moduleDoc:agents/oidc-provisioning.md": "5efa607ff23b9a693391e0c02670324a8cea4114d4968c9718f10a763da919c6",
15
15
  "moduleDoc:agents/mobile-auth.md": "25e85e83f43e3a46383a92fa809f3a003b4545c3026e78dbe1bccbbc35161e18",
@@ -1715,6 +1715,145 @@
1715
1715
  "tags": [],
1716
1716
  "risks": []
1717
1717
  },
1718
+ {
1719
+ "name": "UsersPasswordCredentialCollection",
1720
+ "qualifiedName": "@happyvertical/smrt-users:UsersPasswordCredentialCollection",
1721
+ "collection": "userspasswordcredentials",
1722
+ "tableName": "users_password_credentials",
1723
+ "packageName": "@happyvertical/smrt-users",
1724
+ "extends": "SmrtCollection",
1725
+ "fields": [],
1726
+ "relationships": [],
1727
+ "methods": [
1728
+ "deleteByUserId",
1729
+ "deleteIfCurrent",
1730
+ "findByUserId",
1731
+ "insertIfAbsent",
1732
+ "replaceHashIfUnchanged",
1733
+ "replaceIfCurrent",
1734
+ "upsertForUser"
1735
+ ],
1736
+ "methodSignatures": [
1737
+ {
1738
+ "name": "deleteByUserId",
1739
+ "async": true,
1740
+ "params": [
1741
+ "userId: string"
1742
+ ],
1743
+ "returns": "Promise<boolean>"
1744
+ },
1745
+ {
1746
+ "name": "deleteIfCurrent",
1747
+ "async": true,
1748
+ "params": [
1749
+ "expected: UsersPasswordCredential"
1750
+ ],
1751
+ "returns": "Promise<boolean>"
1752
+ },
1753
+ {
1754
+ "name": "findByUserId",
1755
+ "async": true,
1756
+ "params": [
1757
+ "userId: string"
1758
+ ],
1759
+ "returns": "Promise<UsersPasswordCredential | null>"
1760
+ },
1761
+ {
1762
+ "name": "insertIfAbsent",
1763
+ "async": true,
1764
+ "params": [
1765
+ "userId: string",
1766
+ "write: PasswordCredentialWrite"
1767
+ ],
1768
+ "returns": "Promise<UsersPasswordCredential | null>"
1769
+ },
1770
+ {
1771
+ "name": "replaceHashIfUnchanged",
1772
+ "async": true,
1773
+ "params": [
1774
+ "userId: string",
1775
+ "expectedHash: string",
1776
+ "upgradedHash: string"
1777
+ ],
1778
+ "returns": "Promise<boolean>"
1779
+ },
1780
+ {
1781
+ "name": "replaceIfCurrent",
1782
+ "async": true,
1783
+ "params": [
1784
+ "expected: UsersPasswordCredential",
1785
+ "write: Omit<PasswordCredentialWrite, 'mustChange'>"
1786
+ ],
1787
+ "returns": "Promise<boolean>"
1788
+ },
1789
+ {
1790
+ "name": "upsertForUser",
1791
+ "async": true,
1792
+ "params": [
1793
+ "userId: string",
1794
+ "write: PasswordCredentialWrite"
1795
+ ],
1796
+ "returns": "Promise<UsersPasswordCredential>"
1797
+ }
1798
+ ],
1799
+ "surfaces": [],
1800
+ "withheldSurfaces": [
1801
+ {
1802
+ "kind": "api",
1803
+ "operation": "deleteByUserId",
1804
+ "code": "api-disabled",
1805
+ "reason": "api is disabled",
1806
+ "objectName": "@happyvertical/smrt-users:UsersPasswordCredentialCollection"
1807
+ },
1808
+ {
1809
+ "kind": "api",
1810
+ "operation": "deleteIfCurrent",
1811
+ "code": "api-disabled",
1812
+ "reason": "api is disabled",
1813
+ "objectName": "@happyvertical/smrt-users:UsersPasswordCredentialCollection"
1814
+ },
1815
+ {
1816
+ "kind": "api",
1817
+ "operation": "findByUserId",
1818
+ "code": "api-disabled",
1819
+ "reason": "api is disabled",
1820
+ "objectName": "@happyvertical/smrt-users:UsersPasswordCredentialCollection"
1821
+ },
1822
+ {
1823
+ "kind": "api",
1824
+ "operation": "insertIfAbsent",
1825
+ "code": "api-disabled",
1826
+ "reason": "api is disabled",
1827
+ "objectName": "@happyvertical/smrt-users:UsersPasswordCredentialCollection"
1828
+ },
1829
+ {
1830
+ "kind": "api",
1831
+ "operation": "replaceHashIfUnchanged",
1832
+ "code": "api-disabled",
1833
+ "reason": "api is disabled",
1834
+ "objectName": "@happyvertical/smrt-users:UsersPasswordCredentialCollection"
1835
+ },
1836
+ {
1837
+ "kind": "api",
1838
+ "operation": "replaceIfCurrent",
1839
+ "code": "api-disabled",
1840
+ "reason": "api is disabled",
1841
+ "objectName": "@happyvertical/smrt-users:UsersPasswordCredentialCollection"
1842
+ },
1843
+ {
1844
+ "kind": "api",
1845
+ "operation": "upsertForUser",
1846
+ "code": "api-disabled",
1847
+ "reason": "api is disabled",
1848
+ "objectName": "@happyvertical/smrt-users:UsersPasswordCredentialCollection"
1849
+ }
1850
+ ],
1851
+ "relationshipFeatures": [
1852
+ "uuidColumns"
1853
+ ],
1854
+ "tags": [],
1855
+ "risks": []
1856
+ },
1718
1857
  {
1719
1858
  "name": "PermissionCollection",
1720
1859
  "qualifiedName": "@happyvertical/smrt-users:PermissionCollection",
@@ -2596,7 +2735,8 @@
2596
2735
  "name": "revokeUserSessions",
2597
2736
  "async": true,
2598
2737
  "params": [
2599
- "userId: string"
2738
+ "userId: string",
2739
+ "options?: object"
2600
2740
  ],
2601
2741
  "returns": "Promise<number>"
2602
2742
  },
@@ -5544,6 +5684,66 @@
5544
5684
  "tags": [],
5545
5685
  "risks": []
5546
5686
  },
5687
+ {
5688
+ "name": "UsersPasswordCredential",
5689
+ "qualifiedName": "@happyvertical/smrt-users:UsersPasswordCredential",
5690
+ "collection": "userspasswordcredentials",
5691
+ "tableName": "users_password_credentials",
5692
+ "packageName": "@happyvertical/smrt-users",
5693
+ "extends": "SmrtObject",
5694
+ "fields": [
5695
+ {
5696
+ "name": "userId",
5697
+ "type": "foreignKey",
5698
+ "required": true,
5699
+ "related": "User",
5700
+ "columnType": "UUID"
5701
+ },
5702
+ {
5703
+ "name": "version",
5704
+ "type": "integer",
5705
+ "required": true,
5706
+ "columnType": "INTEGER",
5707
+ "default": 1
5708
+ },
5709
+ {
5710
+ "name": "mustChange",
5711
+ "type": "boolean",
5712
+ "required": true,
5713
+ "columnType": "BOOLEAN",
5714
+ "default": false
5715
+ },
5716
+ {
5717
+ "name": "rotatedAt",
5718
+ "type": "datetime",
5719
+ "required": false,
5720
+ "columnType": "TIMESTAMP"
5721
+ },
5722
+ {
5723
+ "name": "rotatedBy",
5724
+ "type": "text",
5725
+ "required": false,
5726
+ "columnType": "TEXT"
5727
+ }
5728
+ ],
5729
+ "relationships": [
5730
+ {
5731
+ "name": "userId",
5732
+ "type": "foreignKey",
5733
+ "required": true,
5734
+ "related": "User",
5735
+ "columnType": "UUID"
5736
+ }
5737
+ ],
5738
+ "methods": [],
5739
+ "surfaces": [],
5740
+ "relationshipFeatures": [
5741
+ "foreignKey",
5742
+ "uuidColumns"
5743
+ ],
5744
+ "tags": [],
5745
+ "risks": []
5746
+ },
5547
5747
  {
5548
5748
  "name": "Permission",
5549
5749
  "qualifiedName": "@happyvertical/smrt-users:Permission",
@@ -11253,14 +11453,14 @@
11253
11453
  ],
11254
11454
  "prompts": [],
11255
11455
  "relationshipsV2": {
11256
- "foreignKeyFields": 26,
11456
+ "foreignKeyFields": 27,
11257
11457
  "crossPackageRefFields": 1,
11258
11458
  "junctionCollections": 0,
11259
11459
  "hierarchicalObjects": 0,
11260
11460
  "polymorphicAssociations": 0,
11261
- "uuidColumns": 100
11461
+ "uuidColumns": 104
11262
11462
  },
11263
- "agentDoc": "# @happyvertical/smrt-users\n\nMulti-tenant identity, RBAC, hierarchical tenants, sessions, and SvelteKit auth.\n\n## Modules\n\nRead only the module relevant to the change; protocol and provisioning details\nare not prerequisites for unrelated user-package work.\n\n| Module | Scope | Module doc |\n|---|---|---|\n| `src/services/PermissionResolver.ts` | permission precedence, inherited memberships, guards, RLS, role seeding | [agents/permissions.md](agents/permissions.md) |\n| `src/services/OidcLoginService.ts`, collections and OIDC handlers | identity reconciliation, transaction boundaries, migration readiness | [agents/oidc-provisioning.md](agents/oidc-provisioning.md) |\n| `src/services/MobileAuthService.ts` | mobile handshake, bearer sessions, bootstrap extension boundary | [agents/mobile-auth.md](agents/mobile-auth.md) |\n| `src/services/TerminalAuthService.ts`, `src/services/LoginAttemptLimiter.ts`, `src/collections/LoginAttemptCollection.ts` | terminal approval concurrency, shared login budget and lockout (#3273), retry-safe database fixtures | [agents/terminal-auth-testing.md](agents/terminal-auth-testing.md) |\n| `src/services/DeviceCredentialService.ts` | per-person PIN layered on a device session (#3276), verifier seam for other credential kinds | this file, \"Security boundaries\" |\n| `src/retention.ts` | expired session/token/CLI-auth reaping and retention sweep wiring | [agents/retention.md](agents/retention.md) |\n\n## Models and authority\n\n- Users are global; tenant access comes through Membership (unique user/tenant).\n User email is normalized and globally unique through readonly nullable\n `emailKey`. `profileId` is a unique cross-package reference: at most one User\n owns each non-null Profile.\n- Tenant uses STI and a materialized hierarchy, maximum depth 10.\n `hierarchyPath`/`hierarchyLevel` are derived from `parentTenantId` by\n `Tenant.save()` on every save (any caller-supplied value is recomputed) and\n descendants are re-materialized when they change; never hand-maintain them.\n Legacy rows are backfilled with `smrt db:materialize-tenant-hierarchy`\n (`materializeTenantHierarchy()`). Tests that need a corrupt path must write it\n with raw SQL (#3036).\n- Role with `tenantId = null` is available to all tenants; `isSystem` prevents\n deletion. `inheritsToDescendants` is opt-in. Seed owner/admin/member/viewer\n through `RoleCollection.seedSystemRoles()` at application initialization.\n- Group roles apply only in their own tenant. Use `getGroupIdsForTenant()`,\n never cross-tenant `getGroupIds()`, for authorization.\n- Upward visibility is opt-in and read-only: `permissions.ancestorRead`\n ({ roles, collections, maxDepth? }) lets a DESCENDANT membership contribute\n declared `<collection>.read` at an ancestor, only when no membership resolved\n there, intersected with BOTH the role's own catalog grants and the\n principal's effective permissions in that descendant, and only for SYSTEM\n roles (a tenant-scoped role sharing a declared slug is ignored). Off by default, never\n write, never lateral, and never row visibility — sibling rows stay scoped by\n tenancy/RLS. Read the permissions module before changing it.\n- Membership DENY always wins. Direct inactive membership blocks inherited\n authority; a direct active membership pins resolution instead of unioning it\n with ancestors. Read the permissions module before changing these rules.\n- AccessRequest has no generated API/MCP/CLI operations; access it through\n `AccessRequestService`. Its JSON field is `requestContext`, not reserved\n slug-scoping `context`.\n\n## Security boundaries\n\n- Generated REST/MCP operations on identity/RBAC models are list/get only.\n Route authentication does not authorize authority mutations, and these models\n are not tenant-scoped. Use permission-gated services or explicitly checked\n consumer handlers. CLI remains a local-operator surface. Preserve the\n registry assertions in `security-audit-1400.test.ts`.\n- Resource guards take the resource tenant, not the session tenant. Omit a\n session membership when targeting a different tenant; mismatches fail closed.\n `loadSessionContext().tenantAuthorization` must be checked by required-tenant\n consumers: null membership can represent inherited authority.\n- Sessions use secure UUIDs; TTL is seconds (default seven days). Access marks\n expired sessions EXPIRED. Magic-link tokens are single use.\n- `Session.authMethod` is server-set at mint time and never read from the\n client; every mint site in this package sets it. A session with\n `parentSessionId` is valid only while its parent validates\n (`loadSessionContext` enforces this; there is no FK cascade by design), may\n not switch to a tenant other than the parent's, and is revoked with its\n parent by `destroySession`.\n- Credential sign-ins reserve through `LoginAttemptLimiter` BEFORE credential\n work and key the subject on the submitted identifier, never a resolved user,\n so unknown and wrong take the same path. Reservations are fail-closed: keep\n them on failure, release on success or abort, never skip the reserve.\n Limiter writes are raw SQL and bypass the change feed; the audit sink is the\n observability seam, and it must never throw into the sign-in path.\n- `DeviceCredentialService` accepts a person credential only from a\n first-class session whose `authMethod` is a device-enrollment method\n (`terminal` by default) and that the host's `assertEnrolledDevice` confirms.\n A layered or PIN session can never administer PINs regardless of\n permissions. PIN hashes carry a per-row salt and the configured pepper;\n treat an unset pepper as a production misconfiguration.\n- A person session carries the PERSON's authority (resolved from their own\n membership on every load), never the device account's. `Session.data` keys\n in `SESSION_DATA_KEYS` are server-set controls enforced by the model:\n `permissionCeiling` only ever intersects (malformed fails closed to none)\n and suppresses `superAdminBypass`/`systemContext`; `absoluteExpiresAt`\n bounds `extend()` and `isValid()`; `idleSeconds` overrides the resolving\n service's TTL policy. Never write them from client input. The ceiling is a\n sign-in snapshot; `singleOccupant` revokes other children only AFTER a\n successful mint. A `mustReset` sign-in mints with an empty ceiling and\n `setPin` ends that session; do not grant it authority another way.\n- A layered session whose tenant differs from its parent's never loads (null\n is allowed: narrower). Limiter rows carry `retain_until`; retention must\n not fall back to a process-wide horizon.\n- `Session.parentSessionId` is the parent's bearer: sensitive, never a\n `list()` filter (raw-SQL id reads, which also keep revocation sweeps free of\n caller list bounds), never serialized to clients. `users.pin.manage` reaches\n only people whose every active membership is in the actor's tenant (the PIN\n is global per person). A sign-in re-checks the verified\n credential generation AFTER the mint (`stillValid`); keep that ordering.\n Operation guards deny outside a session's ceiling; `loadPersonSession`\n re-checks device enrollment.\n- Tenant switching verifies active membership before writing and rotates the\n session ID for non-null targets, revoking the old session. Persist the returned\n `SwitchTenantResult.sessionId`; `switchSessionTenant()` updates the cookie and\n preserves its security settings. Failed switches mutate nothing; null clears\n do not rotate, and layered sessions never rotate (a replacement would escape\n the revocation sweeps they depend on). Layers do not nest. `SessionCollection.setSessionTenant()` is unguarded and must\n never receive an untrusted tenant ID.\n- OIDC provisioning is atomic and fail-closed. Preserve exact issuer/subject\n identifiers, claim-source email verification, unique global Person ownership,\n and transaction-bound reconciliation. Read the OIDC module and canonical\n scenario matrix before changing any provisioning path.\n\n## Entry points and validation\n\n`src/sveltekit/` owns `createSessionHandler`, `createSessionCookie`,\n`destroySessionCookie`, and `switchSessionTenant`. Use README integration examples\nrather than copying application setup into these instructions.\n\nFrom the repository root:\n\n```bash\npnpm --filter @happyvertical/smrt-users test\npnpm --filter @happyvertical/smrt-users typecheck\npnpm --filter @happyvertical/smrt-users test:postgres\n```\n\nStart with the relevant test file via `test -- src/__tests__/<file>.test.ts`.\nRun `test:postgres` for RLS, principal context, OIDC, or terminal-auth database\nchanges. `typecheck` includes Svelte accessibility checks; plain `tsc` is\ninsufficient. Follow root knowledge freshness checks before shipping.\n",
11463
+ "agentDoc": "# @happyvertical/smrt-users\n\nMulti-tenant identity, RBAC, hierarchical tenants, sessions, and SvelteKit auth.\n\n## Modules\n\nRead only the module relevant to the change; protocol and provisioning details\nare not prerequisites for unrelated user-package work.\n\n| Module | Scope | Module doc |\n|---|---|---|\n| `src/services/PermissionResolver.ts` | permission precedence, inherited memberships, guards, RLS, role seeding | [agents/permissions.md](agents/permissions.md) |\n| `src/services/OidcLoginService.ts`, collections and OIDC handlers | identity reconciliation, transaction boundaries, migration readiness | [agents/oidc-provisioning.md](agents/oidc-provisioning.md) |\n| `src/services/MobileAuthService.ts` | mobile handshake, bearer sessions, bootstrap extension boundary | [agents/mobile-auth.md](agents/mobile-auth.md) |\n| `src/services/TerminalAuthService.ts`, `src/services/LoginAttemptLimiter.ts`, `src/collections/LoginAttemptCollection.ts` | terminal approval concurrency, shared login budget and lockout (#3273), retry-safe database fixtures | [agents/terminal-auth-testing.md](agents/terminal-auth-testing.md) |\n| `src/services/DeviceCredentialService.ts` | per-person PIN layered on a device session (#3276), verifier seam for other credential kinds | this file, \"Security boundaries\" |\n| `src/services/PasswordCredentialService.ts`, `src/sveltekit/password-handlers.ts` | email + password sign-in and password lifecycle (#3274); shared scrypt in `credential-hash.ts` | this file, \"Security boundaries\"; README \"Password sign-in\" |\n| `src/retention.ts` | expired session/token/CLI-auth reaping and retention sweep wiring | [agents/retention.md](agents/retention.md) |\n\n## Models and authority\n\n- Users are global; tenant access comes through Membership (unique user/tenant).\n User email is normalized and globally unique through readonly nullable\n `emailKey`. `profileId` is a unique cross-package reference: at most one User\n owns each non-null Profile.\n- Tenant uses STI and a materialized hierarchy, maximum depth 10.\n `hierarchyPath`/`hierarchyLevel` are derived from `parentTenantId` by\n `Tenant.save()` on every save (any caller-supplied value is recomputed) and\n descendants are re-materialized when they change; never hand-maintain them.\n Legacy rows are backfilled with `smrt db:materialize-tenant-hierarchy`\n (`materializeTenantHierarchy()`). Tests that need a corrupt path must write it\n with raw SQL (#3036).\n- Role with `tenantId = null` is available to all tenants; `isSystem` prevents\n deletion. `inheritsToDescendants` is opt-in. Seed owner/admin/member/viewer\n through `RoleCollection.seedSystemRoles()` at application initialization.\n- Group roles apply only in their own tenant. Use `getGroupIdsForTenant()`,\n never cross-tenant `getGroupIds()`, for authorization.\n- Upward visibility is opt-in and read-only: `permissions.ancestorRead`\n ({ roles, collections, maxDepth? }) lets a DESCENDANT membership contribute\n declared `<collection>.read` at an ancestor, only when no membership resolved\n there, intersected with BOTH the role's own catalog grants and the\n principal's effective permissions in that descendant, and only for SYSTEM\n roles (a tenant-scoped role sharing a declared slug is ignored). Off by default, never\n write, never lateral, and never row visibility — sibling rows stay scoped by\n tenancy/RLS. Read the permissions module before changing it.\n- Membership DENY always wins. Direct inactive membership blocks inherited\n authority; a direct active membership pins resolution instead of unioning it\n with ancestors. Read the permissions module before changing these rules.\n- AccessRequest has no generated API/MCP/CLI operations; access it through\n `AccessRequestService`. Its JSON field is `requestContext`, not reserved\n slug-scoping `context`.\n\n## Security boundaries\n\n- Generated REST/MCP operations on identity/RBAC models are list/get only.\n Route authentication does not authorize authority mutations, and these models\n are not tenant-scoped. Use permission-gated services or explicitly checked\n consumer handlers. CLI remains a local-operator surface. Preserve the\n registry assertions in `security-audit-1400.test.ts`.\n- Resource guards take the resource tenant, not the session tenant. Omit a\n session membership when targeting a different tenant; mismatches fail closed.\n `loadSessionContext().tenantAuthorization` must be checked by required-tenant\n consumers: null membership can represent inherited authority.\n- Sessions use secure UUIDs; TTL is seconds (default seven days). Access marks\n expired sessions EXPIRED. Magic-link tokens are single use.\n- `Session.authMethod` is server-set at mint time and never read from the\n client; every mint site in this package sets it. A session with\n `parentSessionId` is valid only while its parent validates\n (`loadSessionContext` enforces this; there is no FK cascade by design), may\n not switch to a tenant other than the parent's, and is revoked with its\n parent by `destroySession`.\n- Credential sign-ins reserve through `LoginAttemptLimiter` BEFORE credential\n work and key the subject on the submitted identifier, never a resolved user,\n so unknown and wrong take the same path. Reservations are fail-closed: keep\n them on failure, release on success or abort, never skip the reserve.\n Limiter writes are raw SQL and bypass the change feed; the audit sink is the\n observability seam, and it must never throw into the sign-in path.\n- `DeviceCredentialService` accepts a person credential only from a\n first-class session whose `authMethod` is a device-enrollment method\n (`terminal` by default) and that the host's `assertEnrolledDevice` confirms.\n A layered or PIN session can never administer PINs regardless of\n permissions. PIN hashes carry a per-row salt and the configured pepper;\n treat an unset pepper as a production misconfiguration.\n- A person session carries the PERSON's authority (resolved from their own\n membership on every load), never the device account's. `Session.data` keys\n in `SESSION_DATA_KEYS` are server-set controls enforced by the model:\n `permissionCeiling` only ever intersects (malformed fails closed to none)\n and suppresses `superAdminBypass`/`systemContext`; `absoluteExpiresAt`\n bounds `extend()` and `isValid()`; `idleSeconds` overrides the resolving\n service's TTL policy. Never write them from client input. The ceiling is a\n sign-in snapshot; `singleOccupant` revokes other children only AFTER a\n successful mint. A `mustReset` sign-in mints with an empty ceiling and\n `setPin` ends that session; do not grant it authority another way.\n- `UsersPasswordCredential` is one row per person, sensitive, with no\n generated surface; `PasswordCredentialService` and its handlers are its only\n read/write paths. Sign-in normalizes the email like `emailKey`, reserves\n before work, always runs one scrypt verify (dummy hash when absent), never\n creates a user, and maps every non-rate-limit refusal to one\n `PasswordCredentialError`. It re-checks the credential after the mint (a\n rehash that keeps row and version is confirmed by re-verifying); the\n parameter-upgrade write is a guarded UPDATE that must never replace a\n rotated password, and verification against a weaker stored hash is padded\n to the policy's scrypt cost. Self-service writes are guarded on the proven\n credential (first set insert-only); session sweeps run before and after\n each write. Self-service needs the current password except for a first\n set; `users.password.manage` follows the PIN's single-tenant target\n rule and never resets the actor's own. Layered sessions never manage\n passwords; a `mustChange` sign-in mints an empty ceiling.\n- A layered session whose tenant differs from its parent's never loads (null\n is allowed: narrower). Limiter rows carry `retain_until`; retention must\n not fall back to a process-wide horizon.\n- `Session.parentSessionId` is the parent's bearer: sensitive, never a\n `list()` filter (raw-SQL id reads, which also keep revocation sweeps free of\n caller list bounds), never serialized to clients. `users.pin.manage` reaches\n only people whose every active membership is in the actor's tenant (the PIN\n is global per person). A sign-in re-checks the verified\n credential generation AFTER the mint (`stillValid`); keep that ordering.\n Operation guards deny outside a session's ceiling; `loadPersonSession`\n re-checks device enrollment.\n- Tenant switching verifies active membership before writing and rotates the\n session ID for non-null targets, revoking the old session. Persist the returned\n `SwitchTenantResult.sessionId`; `switchSessionTenant()` updates the cookie and\n preserves its security settings. Failed switches mutate nothing; null clears\n do not rotate, and layered sessions never rotate (a replacement would escape\n the revocation sweeps they depend on). Layers do not nest. `SessionCollection.setSessionTenant()` is unguarded and must\n never receive an untrusted tenant ID.\n- OIDC provisioning is atomic and fail-closed. Preserve exact issuer/subject\n identifiers, claim-source email verification, unique global Person ownership,\n and transaction-bound reconciliation. Read the OIDC module and canonical\n scenario matrix before changing any provisioning path.\n\n## Entry points and validation\n\n`src/sveltekit/` owns `createSessionHandler`, `createSessionCookie`,\n`destroySessionCookie`, and `switchSessionTenant`. Use README integration examples\nrather than copying application setup into these instructions.\n\nFrom the repository root:\n\n```bash\npnpm --filter @happyvertical/smrt-users test\npnpm --filter @happyvertical/smrt-users typecheck\npnpm --filter @happyvertical/smrt-users test:postgres\n```\n\nStart with the relevant test file via `test -- src/__tests__/<file>.test.ts`.\nRun `test:postgres` for RLS, principal context, OIDC, or terminal-auth database\nchanges. `typecheck` includes Svelte accessibility checks; plain `tsc` is\ninsufficient. Follow root knowledge freshness checks before shipping.\n",
11264
11464
  "moduleDocs": [
11265
11465
  {
11266
11466
  "path": "agents/permissions.md",
@@ -26,6 +26,7 @@ export type { NormalizedOidcClaims, OidcProfileOwnerAuthorization, OidcProfileOw
26
26
  export { MobileAuthError, type MobileAuthErrorCode, MobileAuthService, type MobileAuthServiceOptions, type MobileBootstrapContext, type MobileLoginContext, type MobileLogoutResult, type MobileRequestMeta, type MobileResolvedUser, type MobileTenantContext, readMobileBearerToken, validateMobileRedirectUri, } from '../services/MobileAuthService.js';
27
27
  export { createDeviceCredentialHandlers, type DeviceCredentialHandlers, } from './device-credential-handlers.js';
28
28
  export { type CreateMobileAuthHandlersOptions, createMobileAuthHandlers, type MobileAuthHandlers, type MobileRequestEvent, type MobileRequestHandler, resolveMobileUploadDedupKey, } from './mobile-handlers.js';
29
+ export { type CreatePasswordCredentialHandlersOptions, createPasswordCredentialHandlers, type PasswordCredentialHandlers, type PasswordRequestEvent, } from './password-handlers.js';
29
30
  export { type CliResource, type CommandDefinition, type CommandKind, type CommandPolicyContext, type CommandScope, type CreateResourceListHandlerOptions, createResourceListHandler, InvalidBearerError, type ResolvedSession, type ResourceListResponseBody, } from './resource-list-handler.js';
30
31
  export { defaultSessionLocals, type SessionLocals } from './types.js';
31
32
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sveltekit/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AASH,OAAO,yBAAyB,CAAC;AAGjC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,KAAK,EACV,0BAA0B,EAC1B,mBAAmB,EACpB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAEL,K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AW,2BAA2B;IAC1C,QAAQ,EAAE,IAAI,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,kEAAkE;AAClE,MAAM,WAAW,2BAA2B;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,WAAW,6BACf,SAAQ,0BAA0B;IAClC,0DAA0D;IAC1D,WAAW,EAAE,CACX,KAAK,EAAE,qBAAqB,KACzB;QAAE,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI,GAAG,SAAS,CAAC;IACtE,iDAAiD;IACjD,eAAe,EAAE,CAAC,KAAK,EAAE,qBAAqB,KAAK,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAC7E,oEAAoE;IACpE,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,CAAC,KAAK,EAAE,qBAAqB,KAAK,OAAO,CAAC,qBAAqB,CAAC,CAAC;IACvE,OAAO,EAAE,CACP,KAAK,EAAE,qBAAqB,KACzB,OAAO,CACR,2BAA2B,GAC3B;QAAE,IAAI,EAAE,SAAS,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,2BAA2B,CAAA;KAAE,CACzE,CAAC;CACH;AAED,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,6BAA6B,GACrC,wBAAwB,CAuF1B;AAuBD,OAAO,EACL,iBAAiB,EACjB,0BAA0B,EAC1B,mBAAmB,EACnB,KAAK,0BAA0B,GAChC,CAAC"}
@@ -0,0 +1,91 @@
1
+ /**
2
+ * SvelteKit glue for {@link PasswordCredentialService} (#3274): browser
3
+ * email + password sign-in that sets the same session cookie
4
+ * `createSessionHandler` reads, and password management for the signed-in
5
+ * person and administrators.
6
+ *
7
+ * ```ts
8
+ * // src/lib/server/password-auth.ts
9
+ * import { createPasswordCredentialHandlers } from '@happyvertical/smrt-users/sveltekit';
10
+ *
11
+ * export const passwordAuth = createPasswordCredentialHandlers({
12
+ * db: { type: 'postgres', url: DATABASE_URL },
13
+ * tenantId: () => SHOP_TENANT_ID, // or (event) => …; omit for tenantless
14
+ * cookieName: 'sid', // must match createSessionHandler
15
+ * });
16
+ *
17
+ * // routes/auth/password/+server.ts → export const POST = passwordAuth.signIn;
18
+ * // routes/account/password/+server.ts → export const PUT = passwordAuth.changePassword;
19
+ * // export const POST = passwordAuth.setPassword;
20
+ * // export const DELETE = passwordAuth.clearPassword;
21
+ * // routes/admin/password-reset/+server.ts → export const POST = passwordAuth.resetPassword;
22
+ * ```
23
+ *
24
+ * Wire contract:
25
+ *
26
+ * - `signIn`: JSON or form body `{ email, password }` (`identifier` is accepted
27
+ * for `email`) → 200 `{ authenticated: true, userId, tenantId, expiresAt,
28
+ * mustChange }` and an httpOnly session cookie; any cookie session the
29
+ * browser held before is revoked. 401 `{ error, code: 'invalid_credentials' }`
30
+ * for every refusal that is not a rate limit (missing field, unknown email,
31
+ * no password, wrong password, inactive user, no membership); 429 +
32
+ * `Retry-After` `{ code: 'rate_limited' }` when the budget is exhausted. The
33
+ * session id is never in the body.
34
+ * - `setPassword` (`{ userId?, password }`), `changePassword`
35
+ * (`{ currentPassword, newPassword }`), `resetPassword`
36
+ * (`{ userId, password, mustChange? }`), `clearPassword`
37
+ * (`{ userId?, currentPassword? }`): act as the session the host's hook put
38
+ * in `event.locals` (which must include `authMethod` — `createSessionHandler`
39
+ * does). 200 `{ revokedSessions }` (`changePassword` adds
40
+ * `signedOut: true` and clears the cookie when it ended the current
41
+ * must-change session); 400 `password_policy` with a displayable message;
42
+ * 401 `invalid_credentials` for a wrong current password; 401
43
+ * `unauthenticated` without a session; 403 `forbidden`; 429 when the
44
+ * current-password check is rate limited.
45
+ *
46
+ * Sign out with `destroySessionCookie`.
47
+ *
48
+ * @packageDocumentation
49
+ */
50
+ import '../__smrt-register__.js';
51
+ import { PasswordCredentialService, type PasswordCredentialServiceOptions } from '../services/PasswordCredentialService.js';
52
+ type Cookies = {
53
+ get: (name: string) => string | undefined;
54
+ set: (name: string, value: string, options?: Record<string, unknown>) => void;
55
+ delete: (name: string, options?: Record<string, unknown>) => void;
56
+ };
57
+ /** The parts of a SvelteKit `RequestEvent` these handlers use. */
58
+ export type PasswordRequestEvent = {
59
+ cookies: Cookies;
60
+ getClientAddress?: () => string;
61
+ locals?: Record<string, unknown>;
62
+ request: Request;
63
+ url: URL;
64
+ };
65
+ export interface CreatePasswordCredentialHandlersOptions extends PasswordCredentialServiceOptions {
66
+ /**
67
+ * Tenant a sign-in enters; the person must hold an active membership in
68
+ * it. A value or a per-request resolver. Null/omitted signs in with no
69
+ * tenant context.
70
+ */
71
+ tenantId?: string | null | ((event: PasswordRequestEvent) => string | null | undefined | Promise<string | null | undefined>);
72
+ /** Session cookie name; must match `createSessionHandler`. Default `sid`. */
73
+ cookieName?: string;
74
+ cookiePath?: string;
75
+ cookieDomain?: string;
76
+ /** Default: secure when the request is https. */
77
+ cookieSecure?: boolean;
78
+ cookieSameSite?: 'strict' | 'lax' | 'none';
79
+ }
80
+ export interface PasswordCredentialHandlers {
81
+ signIn: (event: PasswordRequestEvent) => Promise<Response>;
82
+ setPassword: (event: PasswordRequestEvent) => Promise<Response>;
83
+ changePassword: (event: PasswordRequestEvent) => Promise<Response>;
84
+ resetPassword: (event: PasswordRequestEvent) => Promise<Response>;
85
+ clearPassword: (event: PasswordRequestEvent) => Promise<Response>;
86
+ /** The lazily created service, for form actions and admin screens. */
87
+ service: () => Promise<PasswordCredentialService>;
88
+ }
89
+ export declare function createPasswordCredentialHandlers(options: CreatePasswordCredentialHandlersOptions): PasswordCredentialHandlers;
90
+ export {};
91
+ //# sourceMappingURL=password-handlers.d.ts.map
@@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