@happyvertical/smrt-users 0.60.14 → 0.60.15

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
@@ -9,6 +9,7 @@ are not prerequisites for unrelated user-package work.
9
9
 
10
10
  | Module | Scope | Module doc |
11
11
  |---|---|---|
12
+ | `src/permission-registry.ts` | portable permission metadata registration; same root/service singleton, no authority grants | [agents/permissions.md](agents/permissions.md#portable-metadata-registry-4765) |
12
13
  | `src/services/PermissionResolver.ts` | permission precedence, inherited memberships, guards, RLS, role seeding | [agents/permissions.md](agents/permissions.md) |
13
14
  | `src/services/OidcLoginService.ts`, collections and OIDC handlers | identity reconciliation, transaction boundaries, migration readiness | [agents/oidc-provisioning.md](agents/oidc-provisioning.md) |
14
15
  | `src/services/MobileAuthService.ts` | mobile handshake, bearer sessions, bootstrap extension boundary | [agents/mobile-auth.md](agents/mobile-auth.md) |
@@ -212,3 +212,21 @@ collection's CRUD grants (#3878); `deriveOperationPermissionSlug()` resolves
212
212
  them for class and catalog-slug callers. Catalog generation merges optional
213
213
  `databaseActions` into the target grant's PostgreSQL bindings. CRUD grants
214
214
  cannot themselves be aliased. See core's [generator contract](../../core/agents/generators.md#custom-action-permission-aliases-3878).
215
+
216
+ ## Portable metadata registry (#4765)
217
+
218
+ Browser-safe packages import `registerPermissionDefinitions` and its existing
219
+ `PermissionDefinition` / PostgreSQL binding types from
220
+ `@happyvertical/smrt-users/permission-registry`. This entry imports only shared
221
+ metadata storage. It does not load Users models, catalog database sync, operator
222
+ services, PostgreSQL policy generation or Core filesystem discovery.
223
+
224
+ The old package-root and PermissionCatalogService exports re-export the exact
225
+ same function. Both paths share the existing process-global Map/counter; each
226
+ returned disposer removes only its own registration and may be called repeatedly.
227
+ Definitions retain their original references and normalization/conflict rules
228
+ remain in the server catalog. No second catalog or no-op browser registration is
229
+ introduced. Metadata registration and catalog sync do not grant a user, role,
230
+ tenant or resource permission. Existing persisted grants/current authority checks
231
+ remain required. Use the public portable entry rather than private service paths
232
+ when a model package needs declarations without the server runtime.
@@ -1,4 +1,5 @@
1
1
  import { a as MembershipStatus, c as TenantPermissionEffect, l as TenantStatus, n as DEFAULT_ROLES, o as OverrideEffect, r as DEFAULT_ROLE_SLUGS, s as SessionStatus, u as UserStatus } from "./types-DqUZxluX.js";
2
+ import { n as getRuntimePermissionRegistrations, t as registerPermissionDefinitions } from "./permission-registry-PhcdZvKe.js";
2
3
  import { IN_LIST_CHUNK_SIZE, ObjectRegistry, SmrtCollection, SmrtObject, bumpChangeFeed, chunkArray, crossPackageRef, field, findManifestEntryByQualifiedName, foreignKey, inheritedCollectionSurface, isEmbeddedDatabase, isPostgresDatabase, resolveOperationPermissionAlias, smrt, withEmbeddedWriteTransaction } from "@happyvertical/smrt-core";
3
4
  import { getCurrentTenant, runTenantHierarchyReadScope, withSystemContext } from "@happyvertical/smrt-tenancy";
4
5
  import { AmbiguousOidcIdentityError, CanonicalPersonProfileError, OidcIdentity, OidcIdentityCollection, ProfileCollection, normalizeIdentityEmail } from "@happyvertical/smrt-profiles";
@@ -2131,10 +2132,6 @@ async function writeInSeedingBatches(db, items, write) {
2131
2132
  }
2132
2133
  //#endregion
2133
2134
  //#region src/services/PermissionCatalogService.ts
2134
- function getRuntimePermissionRegistrations() {
2135
- globalThis.__smrtUsersPermissionRegistrations ??= /* @__PURE__ */ new Map();
2136
- return globalThis.__smrtUsersPermissionRegistrations;
2137
- }
2138
2135
  function toSnakeCase(value) {
2139
2136
  return value.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/[-\s]+/g, "_").toLowerCase();
2140
2137
  }
@@ -2494,14 +2491,6 @@ function mergeDefinitionSet(current, incomingDefinitions, source) {
2494
2491
  mergeBindings(existing, definition);
2495
2492
  }
2496
2493
  }
2497
- function registerPermissionDefinitions(definitions) {
2498
- globalThis.__smrtUsersPermissionRegistrationCounter = (globalThis.__smrtUsersPermissionRegistrationCounter ?? 0) + 1;
2499
- const registrationId = globalThis.__smrtUsersPermissionRegistrationCounter;
2500
- getRuntimePermissionRegistrations().set(registrationId, definitions);
2501
- return () => {
2502
- getRuntimePermissionRegistrations().delete(registrationId);
2503
- };
2504
- }
2505
2494
  function definitionChangesPermission(existing, definition) {
2506
2495
  return (definition.name ?? existing.name) !== existing.name || (definition.description ?? existing.description) !== existing.description || (definition.category ?? existing.category) !== existing.category;
2507
2496
  }
@@ -6192,6 +6181,6 @@ var PasswordCredentialService = class PasswordCredentialService {
6192
6181
  }
6193
6182
  };
6194
6183
  //#endregion
6195
- export { PermissionCatalogService as $, InvalidCredentialsError as A, SESSION_DATA_KEYS as At, backfillUserEmailKeys as B, DEFAULT_LOGIN_ATTEMPT_WINDOW_SECONDS as C, UsersLoginAttempt as Ct, DEFAULT_LOGIN_MAX_ATTEMPTS as D, normalizeEmail as Dt, DEFAULT_LOGIN_LOCKOUT_MAX_SECONDS as E, isValidEmail as Et, OidcProvisioningError as F, Membership as Ft, MAX_TENANT_HIERARCHY_DEPTH as G, TenantPermissionOverride as H, UserCollection as I, __exportAll as It, assertTenantTableName as J, TenantHierarchyError as K, requireExistingOwnedPerson as L, LoginRateLimitError as M, generateSessionId as Mt, hashSecret as N, Role as Nt, DEFAULT_SOURCE_LOCKOUT_AUDIT_SECONDS as O, normalizeUsername as Ot, verifySecretHash as P, Permission as Pt, RolePermissionCollection as Q, USER_EMAIL_KEY_BACKFILL_NAME as R, normalizeAncestorReadPolicy as S, UsersLoginAttemptCollection as St, DEFAULT_LOGIN_LOCKOUT_FACTOR as T, User as Tt, TenantCollection as U, TenantPermissionOverrideCollection as V, Tenant as W, recordTenantHierarchyChanges as X, planTenantHierarchy as Y, DEFAULT_ROLE_PERMISSION_PATTERNS as Z, PermissionResolver as _, GroupMember as _t, DEFAULT_PASSWORD_RECOVERY_MAX_AGE_SECONDS as a, withoutListBounds as at, getConfiguredAncestorReadPolicy as b, UsersLoginAuditEventCollection as bt, PASSWORD_PERMISSION_DEFINITIONS as c, PermissionCollection as ct, PasswordCredentialForbiddenError as d, MembershipOverrideCollection as dt, deriveOperationPermissionCollectionName as et, PasswordCredentialService as f, MembershipOverride as ft, SessionService as g, GroupMemberCollection as gt, outOfBandProofSessionData as h, GroupRole as ht, DEFAULT_PASSWORD_MIN_LENGTH as i, syncPermissionCatalog as it, LoginAttemptLimiter as j, Session as jt, DurableLoginAuditSink as k, DEFAULT_SESSION_TTL as kt, PASSWORD_RECOVERY_MAX_AGE_CEILING_SECONDS as l, UsersPasswordCredentialCollection as lt, ensurePasswordPermissionsRegistered as m, GroupRoleCollection as mt, DEFAULT_PASSWORD_MANAGE_PERMISSION as n, normalizeOperationPermissionAction as nt, PASSWORD_LOGIN_KIND as o, RolePermission as ot, PasswordPolicyError as p, MembershipCollection as pt, applyTenantHierarchyUpdates as q, DEFAULT_PASSWORD_MAX_LENGTH as r, registerPermissionDefinitions as rt, PASSWORD_MAX_LENGTH_CEILING as s, RoleCollection as st, DEFAULT_PASSWORD_DENYLIST as t, deriveOperationPermissionSlug as tt, PasswordCredentialError as u, UsersPasswordCredential as ut, ANCESTOR_READ_ACTION as v, GroupCollection as vt, DEFAULT_LOGIN_LOCKOUT_BASE_SECONDS as w, SessionCollection as wt, isAncestorReadableSlug as x, UsersLoginAuditEvent as xt, DEFAULT_ANCESTOR_READ_MAX_DEPTH as y, Group as yt, UserEmailKeyBackfillError as z };
6184
+ export { PermissionCatalogService as $, InvalidCredentialsError as A, Session as At, backfillUserEmailKeys as B, DEFAULT_LOGIN_ATTEMPT_WINDOW_SECONDS as C, SessionCollection as Ct, DEFAULT_LOGIN_MAX_ATTEMPTS as D, normalizeUsername as Dt, DEFAULT_LOGIN_LOCKOUT_MAX_SECONDS as E, normalizeEmail as Et, OidcProvisioningError as F, __exportAll as Ft, MAX_TENANT_HIERARCHY_DEPTH as G, TenantPermissionOverride as H, UserCollection as I, assertTenantTableName as J, TenantHierarchyError as K, requireExistingOwnedPerson as L, LoginRateLimitError as M, Role as Mt, hashSecret as N, Permission as Nt, DEFAULT_SOURCE_LOCKOUT_AUDIT_SECONDS as O, DEFAULT_SESSION_TTL as Ot, verifySecretHash as P, Membership as Pt, RolePermissionCollection as Q, USER_EMAIL_KEY_BACKFILL_NAME as R, normalizeAncestorReadPolicy as S, UsersLoginAttempt as St, DEFAULT_LOGIN_LOCKOUT_FACTOR as T, isValidEmail as Tt, TenantCollection as U, TenantPermissionOverrideCollection as V, Tenant as W, recordTenantHierarchyChanges as X, planTenantHierarchy as Y, DEFAULT_ROLE_PERMISSION_PATTERNS as Z, PermissionResolver as _, GroupCollection as _t, DEFAULT_PASSWORD_RECOVERY_MAX_AGE_SECONDS as a, RolePermission as at, getConfiguredAncestorReadPolicy as b, UsersLoginAuditEvent as bt, PASSWORD_PERMISSION_DEFINITIONS as c, UsersPasswordCredentialCollection as ct, PasswordCredentialForbiddenError as d, MembershipOverride as dt, deriveOperationPermissionCollectionName as et, PasswordCredentialService as f, MembershipCollection as ft, SessionService as g, GroupMember as gt, outOfBandProofSessionData as h, GroupMemberCollection as ht, DEFAULT_PASSWORD_MIN_LENGTH as i, withoutListBounds as it, LoginAttemptLimiter as j, generateSessionId as jt, DurableLoginAuditSink as k, SESSION_DATA_KEYS as kt, PASSWORD_RECOVERY_MAX_AGE_CEILING_SECONDS as l, UsersPasswordCredential as lt, ensurePasswordPermissionsRegistered as m, GroupRole as mt, DEFAULT_PASSWORD_MANAGE_PERMISSION as n, normalizeOperationPermissionAction as nt, PASSWORD_LOGIN_KIND as o, RoleCollection as ot, PasswordPolicyError as p, GroupRoleCollection as pt, applyTenantHierarchyUpdates as q, DEFAULT_PASSWORD_MAX_LENGTH as r, syncPermissionCatalog as rt, PASSWORD_MAX_LENGTH_CEILING as s, PermissionCollection as st, DEFAULT_PASSWORD_DENYLIST as t, deriveOperationPermissionSlug as tt, PasswordCredentialError as u, MembershipOverrideCollection as ut, ANCESTOR_READ_ACTION as v, Group as vt, DEFAULT_LOGIN_LOCKOUT_BASE_SECONDS as w, User as wt, isAncestorReadableSlug as x, UsersLoginAttemptCollection as xt, DEFAULT_ANCESTOR_READ_MAX_DEPTH as y, UsersLoginAuditEventCollection as yt, UserEmailKeyBackfillError as z };
6196
6185
 
6197
- //# sourceMappingURL=PasswordCredentialService-BSSP_kyT.js.map
6186
+ //# sourceMappingURL=PasswordCredentialService-AL5GT_UL.js.map