@happyvertical/smrt-users 0.57.6 → 0.57.8

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/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as PermissionResolver, $t as GroupCollection, A as withSessionPermissionContext, At as recordTenantHierarchyChanges, B as resolveOidcProviderConfig, Bt as RoleCollection, C as OperationPermissionError, Ct as TenantCollection, D as getCurrentSessionPermissionContext, Dt as applyTenantHierarchyUpdates, E as hasOperationPermission, Et as TenantHierarchyError, F as OidcLoginError, Ft as deriveOperationPermissionSlug, G as DeviceCredentialForbiddenError, Gt as UsersPasswordCredential, H as DEFAULT_DEVICE_PERSON_IDLE_SECONDS, Ht as UsersPinCredential, I as OidcLoginService, It as normalizeOperationPermissionAction, J as PIN_LOGIN_KIND, Jt as MembershipCollection, K as DeviceCredentialPolicyError, Kt as MembershipOverrideCollection, L as decodeOidcTransaction, Lt as registerPermissionDefinitions, M as MobileAuthService, Mt as RolePermissionCollection, N as readMobileBearerToken, Nt as PermissionCatalogService, O as getRequestScopedDatabase, Ot as assertTenantTableName, P as validateMobileRedirectUri, Pt as deriveOperationPermissionCollectionName, Q as SessionService, Qt as GroupMember, R as encodeOidcTransaction, Rt as syncPermissionCatalog, S as outOfBandProofSessionData, St as TenantPermissionOverride, T as checkOperationPermission, Tt as MAX_TENANT_HIERARCHY_DEPTH, U as DEFAULT_PIN_MANAGE_PERMISSION, Ut as PermissionCollection, Vt as UsersPinCredentialCollection, W as DeviceCredentialError, Wt as UsersPasswordCredentialCollection, X as PinVerifier, Xt as GroupRole, Y as PIN_PERMISSION_DEFINITIONS, Yt as GroupRoleCollection, Z as ensurePinPermissionsRegistered, Zt as GroupMemberCollection, _ as PasswordCredentialError, _n as Membership, _t as UserCollection, a as TerminalAuthError, an as UsersCliAuthRequestCollection, at as DEFAULT_SOURCE_LOCKOUT_AUDIT_SECONDS, b as PasswordPolicyError, bt as backfillUserEmailKeys, c as DEFAULT_PASSWORD_DENYLIST, cn as User, ct as LoginAttemptLimiter, d as DEFAULT_PASSWORD_MIN_LENGTH, dn as DEFAULT_SESSION_TTL, dt as ANCESTOR_READ_ACTION, en as Group, et as DEFAULT_LOGIN_ATTEMPT_WINDOW_SECONDS, f as DEFAULT_PASSWORD_RECOVERY_MAX_AGE_SECONDS, fn as SESSION_DATA_KEYS, ft as DEFAULT_ANCESTOR_READ_MAX_DEPTH, g as PASSWORD_RECOVERY_MAX_AGE_CEILING_SECONDS, gn as Permission, gt as OidcProvisioningError, h as PASSWORD_PERMISSION_DEFINITIONS, hn as Role, ht as normalizeAncestorReadPolicy, i as TERMINAL_APPROVE_LOGIN_KIND, in as UsersLoginAttempt, it as DEFAULT_LOGIN_MAX_ATTEMPTS, j as MobileAuthError, jt as DEFAULT_ROLE_PERMISSION_PATTERNS, k as withPrincipalPermissionContext, kt as planTenantHierarchy, l as DEFAULT_PASSWORD_MANAGE_PERMISSION, ln as isValidEmail, lt as LoginRateLimitError, m as PASSWORD_MAX_LENGTH_CEILING, mn as generateSessionId, mt as isAncestorReadableSlug, n as DEFAULT_CLI_AUTH_REQUEST_TTL_SECONDS, nn as UsersLoginAuditEvent, nt as DEFAULT_LOGIN_LOCKOUT_FACTOR, o as TerminalAuthRateLimitError, on as SessionCollection, ot as DurableLoginAuditSink, p as PASSWORD_LOGIN_KIND, pn as Session, pt as getConfiguredAncestorReadPolicy, q as DeviceCredentialService, qt as MembershipOverride, r as DEFAULT_CLI_SESSION_TTL_SECONDS, rn as UsersLoginAttemptCollection, rt as DEFAULT_LOGIN_LOCKOUT_MAX_SECONDS, s as TerminalAuthService, sn as UsersCliAuthRequest, st as InvalidCredentialsError, t as DEFAULT_CLI_AUTH_POLL_INTERVAL_SECONDS, tn as UsersLoginAuditEventCollection, tt as DEFAULT_LOGIN_LOCKOUT_BASE_SECONDS, u as DEFAULT_PASSWORD_MAX_LENGTH, un as normalizeEmail, ut as withoutListBounds, v as PasswordCredentialForbiddenError, w as assertOperationPermission, wt as Tenant, x as ensurePasswordPermissionsRegistered, xt as TenantPermissionOverrideCollection, y as PasswordCredentialService, yt as UserEmailKeyBackfillError, z as getUsersOidcConfig, zt as RolePermission } from "./chunks/TerminalAuthService-BqdDnJ4T.js";
1
+ import { $ as PermissionResolver, $t as GroupCollection, A as withSessionPermissionContext, At as recordTenantHierarchyChanges, B as resolveOidcProviderConfig, Bt as RoleCollection, C as OperationPermissionError, Ct as TenantCollection, D as getCurrentSessionPermissionContext, Dt as applyTenantHierarchyUpdates, E as hasOperationPermission, Et as TenantHierarchyError, F as OidcLoginError, Ft as deriveOperationPermissionSlug, G as DeviceCredentialForbiddenError, Gt as UsersPasswordCredential, H as DEFAULT_DEVICE_PERSON_IDLE_SECONDS, Ht as UsersPinCredential, I as OidcLoginService, It as normalizeOperationPermissionAction, J as PIN_LOGIN_KIND, Jt as MembershipCollection, K as DeviceCredentialPolicyError, Kt as MembershipOverrideCollection, L as decodeOidcTransaction, Lt as registerPermissionDefinitions, M as MobileAuthService, Mt as RolePermissionCollection, N as readMobileBearerToken, Nt as PermissionCatalogService, O as getRequestScopedDatabase, Ot as assertTenantTableName, P as validateMobileRedirectUri, Pt as deriveOperationPermissionCollectionName, Q as SessionService, Qt as GroupMember, R as encodeOidcTransaction, Rt as syncPermissionCatalog, S as outOfBandProofSessionData, St as TenantPermissionOverride, T as checkOperationPermission, Tt as MAX_TENANT_HIERARCHY_DEPTH, U as DEFAULT_PIN_MANAGE_PERMISSION, Ut as PermissionCollection, Vt as UsersPinCredentialCollection, W as DeviceCredentialError, Wt as UsersPasswordCredentialCollection, X as PinVerifier, Xt as GroupRole, Y as PIN_PERMISSION_DEFINITIONS, Yt as GroupRoleCollection, Z as ensurePinPermissionsRegistered, Zt as GroupMemberCollection, _ as PasswordCredentialError, _n as Membership, _t as UserCollection, a as TerminalAuthError, an as UsersCliAuthRequestCollection, at as DEFAULT_SOURCE_LOCKOUT_AUDIT_SECONDS, b as PasswordPolicyError, bt as backfillUserEmailKeys, c as DEFAULT_PASSWORD_DENYLIST, cn as User, ct as LoginAttemptLimiter, d as DEFAULT_PASSWORD_MIN_LENGTH, dn as DEFAULT_SESSION_TTL, dt as ANCESTOR_READ_ACTION, en as Group, et as DEFAULT_LOGIN_ATTEMPT_WINDOW_SECONDS, f as DEFAULT_PASSWORD_RECOVERY_MAX_AGE_SECONDS, fn as SESSION_DATA_KEYS, ft as DEFAULT_ANCESTOR_READ_MAX_DEPTH, g as PASSWORD_RECOVERY_MAX_AGE_CEILING_SECONDS, gn as Permission, gt as OidcProvisioningError, h as PASSWORD_PERMISSION_DEFINITIONS, hn as Role, ht as normalizeAncestorReadPolicy, i as TERMINAL_APPROVE_LOGIN_KIND, in as UsersLoginAttempt, it as DEFAULT_LOGIN_MAX_ATTEMPTS, j as MobileAuthError, jt as DEFAULT_ROLE_PERMISSION_PATTERNS, k as withPrincipalPermissionContext, kt as planTenantHierarchy, l as DEFAULT_PASSWORD_MANAGE_PERMISSION, ln as isValidEmail, lt as LoginRateLimitError, m as PASSWORD_MAX_LENGTH_CEILING, mn as generateSessionId, mt as isAncestorReadableSlug, n as DEFAULT_CLI_AUTH_REQUEST_TTL_SECONDS, nn as UsersLoginAuditEvent, nt as DEFAULT_LOGIN_LOCKOUT_FACTOR, o as TerminalAuthRateLimitError, on as SessionCollection, ot as DurableLoginAuditSink, p as PASSWORD_LOGIN_KIND, pn as Session, pt as getConfiguredAncestorReadPolicy, q as DeviceCredentialService, qt as MembershipOverride, r as DEFAULT_CLI_SESSION_TTL_SECONDS, rn as UsersLoginAttemptCollection, rt as DEFAULT_LOGIN_LOCKOUT_MAX_SECONDS, s as TerminalAuthService, sn as UsersCliAuthRequest, st as InvalidCredentialsError, t as DEFAULT_CLI_AUTH_POLL_INTERVAL_SECONDS, tn as UsersLoginAuditEventCollection, tt as DEFAULT_LOGIN_LOCKOUT_BASE_SECONDS, u as DEFAULT_PASSWORD_MAX_LENGTH, un as normalizeEmail, ut as withoutListBounds, v as PasswordCredentialForbiddenError, w as assertOperationPermission, wt as Tenant, x as ensurePasswordPermissionsRegistered, xt as TenantPermissionOverrideCollection, y as PasswordCredentialService, yt as UserEmailKeyBackfillError, z as getUsersOidcConfig, zt as RolePermission } from "./chunks/TerminalAuthService-BpRwohDW.js";
2
2
  import { a as MembershipStatus, c as TenantPermissionEffect, i as DEFAULT_TENANT_POLICY, l as TenantStatus, n as DEFAULT_ROLES, o as OverrideEffect, r as DEFAULT_ROLE_SLUGS, s as SessionStatus, t as AccessRequestStatus, u as UserStatus } from "./chunks/types-DFqeph0R.js";
3
3
  import { ObjectRegistry, SmrtCollection, SmrtObject, SmrtRecipe, bumpChangeFeed, crossPackageRef, ensureChangeFeedTable, field, findManifestEntryByQualifiedName, foreignKey, isEmbeddedDatabase, isUniqueViolationError, registerRetentionTask, smrt, unregisterRetentionTask, withEmbeddedWriteTransaction } from "@happyvertical/smrt-core";
4
4
  import { TenantScoped, getTenantId, tenantId, withSystemContext, withTenant, withTenantGlobalRead } from "@happyvertical/smrt-tenancy";
@@ -2552,7 +2552,7 @@ var MagicLinkService = class MagicLinkService {
2552
2552
  * The caller is responsible for emailing the token to the user.
2553
2553
  */
2554
2554
  async generate(email) {
2555
- const { SignJWT } = await import("./chunks/TerminalAuthService-BqdDnJ4T.js").then((n) => n.V);
2555
+ const { SignJWT } = await import("./chunks/TerminalAuthService-BpRwohDW.js").then((n) => n.V);
2556
2556
  const key = await this.getSigningKey();
2557
2557
  const nonce = crypto.randomUUID();
2558
2558
  const normalizedEmail = normalizeEmail(email);
@@ -2581,7 +2581,7 @@ var MagicLinkService = class MagicLinkService {
2581
2581
  * @throws {MagicLinkError} If the token is invalid, expired, or already used
2582
2582
  */
2583
2583
  async verify(token) {
2584
- const { jwtVerify, errors } = await import("./chunks/TerminalAuthService-BqdDnJ4T.js").then((n) => n.V);
2584
+ const { jwtVerify, errors } = await import("./chunks/TerminalAuthService-BpRwohDW.js").then((n) => n.V);
2585
2585
  const key = await this.getSigningKey();
2586
2586
  let payload;
2587
2587
  try {
@@ -2,7 +2,7 @@
2
2
  "version": "1.0.0",
3
3
  "timestamp": 0,
4
4
  "packageName": "@happyvertical/smrt-users",
5
- "packageVersion": "0.57.6",
5
+ "packageVersion": "0.57.8",
6
6
  "objects": {
7
7
  "@happyvertical/smrt-users:AccessRequestCollection": {
8
8
  "name": "accessrequestcollection",
@@ -6018,7 +6018,7 @@
6018
6018
  "collectionExportName": "UserCollectionCollection",
6019
6019
  "schema": {
6020
6020
  "tableName": "users",
6021
- "ddl": "CREATE TABLE IF NOT EXISTS \"users\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"profile_id\" UUID UNIQUE,\n \"email\" TEXT DEFAULT '',\n \"email_key\" TEXT UNIQUE,\n \"status\" TEXT,\n \"last_login_at\" TIMESTAMP\n);",
6021
+ "ddl": "CREATE TABLE IF NOT EXISTS \"users\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"profile_id\" UUID UNIQUE,\n \"email\" TEXT DEFAULT '',\n \"email_key\" TEXT UNIQUE,\n \"username\" TEXT,\n \"username_key\" TEXT UNIQUE,\n \"status\" TEXT,\n \"last_login_at\" TIMESTAMP\n);",
6022
6022
  "columns": {
6023
6023
  "id": {
6024
6024
  "type": "UUID",
@@ -6062,6 +6062,16 @@
6062
6062
  "notNull": false,
6063
6063
  "unique": true
6064
6064
  },
6065
+ "username": {
6066
+ "type": "TEXT",
6067
+ "notNull": false,
6068
+ "unique": false
6069
+ },
6070
+ "username_key": {
6071
+ "type": "TEXT",
6072
+ "notNull": false,
6073
+ "unique": true
6074
+ },
6065
6075
  "status": {
6066
6076
  "type": "TEXT",
6067
6077
  "notNull": false,
@@ -6088,6 +6098,12 @@
6088
6098
  "email"
6089
6099
  ]
6090
6100
  },
6101
+ {
6102
+ "name": "users_username_idx",
6103
+ "columns": [
6104
+ "username"
6105
+ ]
6106
+ },
6091
6107
  {
6092
6108
  "name": "users_created_at_idx",
6093
6109
  "columns": [
@@ -6095,7 +6111,7 @@
6095
6111
  ]
6096
6112
  }
6097
6113
  ],
6098
- "version": "38fd1677"
6114
+ "version": "3ee8f0f4"
6099
6115
  },
6100
6116
  "importPath": "@happyvertical/smrt-users"
6101
6117
  },
@@ -13991,6 +14007,28 @@
13991
14007
  },
13992
14008
  "readonly": true
13993
14009
  },
14010
+ "username": {
14011
+ "type": "text",
14012
+ "required": false,
14013
+ "description": "Optional username used to sign in; lowercase and globally unique.",
14014
+ "_meta": {
14015
+ "description": "Optional username used to sign in; lowercase and globally unique.",
14016
+ "nullable": true,
14017
+ "indexed": true
14018
+ }
14019
+ },
14020
+ "usernameKey": {
14021
+ "type": "text",
14022
+ "required": false,
14023
+ "description": "The standardized username used to recognize this account; maintained automatically.",
14024
+ "_meta": {
14025
+ "description": "The standardized username used to recognize this account; maintained automatically.",
14026
+ "nullable": true,
14027
+ "unique": true,
14028
+ "readonly": true
14029
+ },
14030
+ "readonly": true
14031
+ },
13994
14032
  "status": {
13995
14033
  "type": "text",
13996
14034
  "required": false,
@@ -14083,7 +14121,7 @@
14083
14121
  "collectionExportName": "UserCollection",
14084
14122
  "schema": {
14085
14123
  "tableName": "users",
14086
- "ddl": "CREATE TABLE IF NOT EXISTS \"users\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"profile_id\" UUID UNIQUE,\n \"email\" TEXT DEFAULT '',\n \"email_key\" TEXT UNIQUE,\n \"status\" TEXT,\n \"last_login_at\" TIMESTAMP\n);",
14124
+ "ddl": "CREATE TABLE IF NOT EXISTS \"users\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"profile_id\" UUID UNIQUE,\n \"email\" TEXT DEFAULT '',\n \"email_key\" TEXT UNIQUE,\n \"username\" TEXT,\n \"username_key\" TEXT UNIQUE,\n \"status\" TEXT,\n \"last_login_at\" TIMESTAMP\n);",
14087
14125
  "columns": {
14088
14126
  "id": {
14089
14127
  "type": "UUID",
@@ -14127,6 +14165,16 @@
14127
14165
  "notNull": false,
14128
14166
  "unique": true
14129
14167
  },
14168
+ "username": {
14169
+ "type": "TEXT",
14170
+ "notNull": false,
14171
+ "unique": false
14172
+ },
14173
+ "username_key": {
14174
+ "type": "TEXT",
14175
+ "notNull": false,
14176
+ "unique": true
14177
+ },
14130
14178
  "status": {
14131
14179
  "type": "TEXT",
14132
14180
  "notNull": false,
@@ -14153,6 +14201,12 @@
14153
14201
  "email"
14154
14202
  ]
14155
14203
  },
14204
+ {
14205
+ "name": "users_username_idx",
14206
+ "columns": [
14207
+ "username"
14208
+ ]
14209
+ },
14156
14210
  {
14157
14211
  "name": "users_created_at_idx",
14158
14212
  "columns": [
@@ -14160,7 +14214,7 @@
14160
14214
  ]
14161
14215
  }
14162
14216
  ],
14163
- "version": "38fd1677"
14217
+ "version": "3ee8f0f4"
14164
14218
  },
14165
14219
  "importPath": "@happyvertical/smrt-users"
14166
14220
  }
@@ -11,6 +11,7 @@ import { UserStatus } from '../types/index.js';
11
11
  export interface UserOptions extends SmrtObjectOptions {
12
12
  profileId?: string;
13
13
  email?: string;
14
+ username?: string | null;
14
15
  status?: UserStatus;
15
16
  lastLoginAt?: Date | null;
16
17
  }
@@ -26,6 +27,8 @@ export declare function isValidEmail(email: string): boolean;
26
27
  * @returns Normalized email
27
28
  */
28
29
  export declare function normalizeEmail(email: string): string;
30
+ /** Normalize a username into its globally unique login identity. */
31
+ export declare function normalizeUsername(username: string | null | undefined): string;
29
32
  /**
30
33
  * User represents an authenticated identity in the system.
31
34
  *
@@ -59,6 +62,10 @@ export declare class User extends SmrtObject implements UserContract {
59
62
  email: string;
60
63
  /** Durable normalized key for cross-connection email uniqueness. */
61
64
  emailKey: string | null;
65
+ /** Optional globally unique username login identity. */
66
+ username: string | null;
67
+ /** Durable canonical username key used for cross-connection uniqueness. */
68
+ usernameKey: string | null;
62
69
  /**
63
70
  * User account status
64
71
  */
@@ -1 +1 @@
1
- {"version":3,"file":"User.d.ts","sourceRoot":"","sources":["../../src/models/User.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAGL,UAAU,EACV,KAAK,iBAAiB,EAEvB,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,EAAE,IAAI,IAAI,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C;;GAEG;AACH,MAAM,WAAW,WAAY,SAAQ,iBAAiB;IACpD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,WAAW,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;CAC3B;AAQD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAGnD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAGpD;AAED;;;;;;;;;;;;;;;GAeG;AACH,qBAQa,IAAK,SAAQ,UAAW,YAAW,YAAY;IAC1D;;OAEG;IAGH,SAAS,EAAE,MA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CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAI7E;AAED;;;;;;;;;;;;;;;GAeG;AACH,qBAQa,IAAK,SAAQ,UAAW,YAAW,YAAY;IAC1D;;OAEG;IAGH,SAAS,EAAE,MAAM,CAAM;IAEvB;;;;;;;;OAQG;IAKH,KAAK,EAAE,MAAM,CAAM;IAEnB,oEAAoE;IASpE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAQ;IAE/B,wDAAwD;IAQxD,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAQ;IAE/B,2EAA2E;IAS3E,WAAW,EAAE,MAAM,GAAG,IAAI,CAAQ;IAElC;;OAEG;IAMH,MAAM,EAAE,UAAU,CAAqB;IAEvC;;OAEG;IAEH,WAAW,EAAE,IAAI,GAAG,IAAI,CAAQ;gBAEpB,OAAO,GAAE,WAAgB;IAWrC;;;OAGG;IACH,aAAa,IAAI,OAAO;IAIxB;;OAEG;IACH,QAAQ,IAAI,OAAO;IAInB;;OAEG;IACH,WAAW,IAAI,OAAO;IAItB;;OAEG;IACH,SAAS,IAAI,OAAO;IAIpB;;OAEG;IACH,WAAW,IAAI,IAAI;IAInB,sEAAsE;IACvD,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAOrC"}
@@ -98,6 +98,8 @@ export interface PasswordPolicyContext {
98
98
  userId: string;
99
99
  /** Their normalized email, when they have one. */
100
100
  email: string | null;
101
+ /** Their canonical username, when they have one. */
102
+ username: string | null;
101
103
  }
102
104
  export interface PasswordPolicyOptions {
103
105
  /** Minimum length in characters (Unicode code points, after NFKC). Default 10. */
@@ -196,7 +198,7 @@ export interface PasswordCredentialServiceOptions extends SmrtClassOptions {
196
198
  recovery?: PasswordRecoveryOptions;
197
199
  }
198
200
  export interface PasswordSignInInput {
199
- /** What the person typed as their email; normalized like `User.emailKey`. */
201
+ /** What the person typed as an email or username. */
200
202
  identifier: string;
201
203
  password: string;
202
204
  /**
@@ -204,7 +206,7 @@ export interface PasswordSignInInput {
204
206
  * in it; when null/omitted the session carries no tenant context (and so
205
207
  * no tenant permissions) until `switchSessionTenant`.
206
208
  */
207
- tenantId?: string | null;
209
+ tenantId?: string | null | 'unique-active-membership';
208
210
  ipAddress?: string;
209
211
  userAgent?: string;
210
212
  /**
@@ -350,7 +352,14 @@ export declare class PasswordCredentialService {
350
352
  * {@link PasswordPolicyError}.
351
353
  */
352
354
  validatePassword(password: string, userId: string): Promise<void>;
353
- private findUserByEmailKey;
355
+ private findUserByIdentity;
356
+ /**
357
+ * Select a tenant only when a password-authenticated person has exactly one
358
+ * active direct membership. This is resolved after credential verification:
359
+ * callers never need a tenant locator before sign-in, and ambiguity cannot
360
+ * turn a successful password check into an unscoped session.
361
+ */
362
+ private resolveUniqueActiveMembershipTenant;
354
363
  private requireUser;
355
364
  /**
356
365
  * Prove the current password for a self-service change or clear, through
@@ -1 +1 @@
1
- {"version":3,"file":"PasswordCredentialService.d.ts","sourceRoot":"","sources":["../../src/services/PasswordCredentialService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AAGH,OAAO,EAEL,KAAK,gBAAgB,EAEtB,MAAM,0BAA0B,CAAC;AAQlC,OAAO,EAGL,KAAK,iBAAiB,EACvB,MAAM,sBAAsB,CAAC;AAI9B,OAAO,EAIL,KAAK,YAAY,EAGlB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,uBAAuB,EACvB,mBAAmB,EACnB,KAAK,0BAA0B,EAEhC,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,KAAK,oBAAoB,EAE1B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,KAAK,cAAc,EAAkB,MAAM,qBAAqB,CAAC;AAE1E,yEAAyE;AACzE,eAAO,MAAM,mBAAmB,aAAa,CAAC;AAC9C,qFAAqF;AACrF,eAAO,MAAM,kCAAkC,0BAA0B,CAAC;AAC1E,sDAAsD;AACtD,e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mB,EAAE,OAAO,CAAA;KAAE,CAAC;IA8CrE;;;;OAIG;IACG,aAAa,CACjB,KAAK,EAAE,kBAAkB,GACxB,OAAO,CAAC;QAAE,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC;IAoCvC;;;;OAIG;IACG,aAAa,CACjB,KAAK,EAAE,kBAAkB,GACxB,OAAO,CAAC;QAAE,eAAe,EAAE,MAAM,CAAA;KAAE,CAAC;IAwCvC;;;;;;;;;;;;OAYG;IACG,wBAAwB,CAC5B,KAAK,EAAE,6BAA6B,GACnC,OAAO,CAAC;QAAE,eAAe,EAAE,MAAM,CAAC;QAAC,mBAAmB,EAAE,IAAI,CAAA;KAAE,CAAC;IAkHlE,sFAAsF;IAChF,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAKnD;;;;OAIG;IACG,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;YAQzD,kBAAkB;IAahC;;;;;OAKG;YACW,mCAAmC;YAWnC,WAAW;IAQzB;;;;OAIG;YACW,aAAa;IAqC3B,OAAO,CAAC,gBAAgB;YAQV,eAAe;IA8B7B,sFAAsF;YACxE,YAAY;IA0C1B,OAAO,CAAC,YAAY;IAIpB;;;;;;;OAOG;YACW,eAAe;IAU7B;;;;;OAKG;YACW,mBAAmB;YAwBnB,gBAAgB;CAY/B"}
@@ -3,12 +3,12 @@
3
3
  "sensitiveFieldsExcluded": true,
4
4
  "generatedAt": "1970-01-01T00:00:00.000Z",
5
5
  "packageName": "@happyvertical/smrt-users",
6
- "packageVersion": "0.57.6",
6
+ "packageVersion": "0.57.8",
7
7
  "sourceManifestPath": "dist/manifest.json",
8
8
  "agentDocPath": "AGENTS.md",
9
9
  "sourceHashes": {
10
- "manifest": "86561cc96aaa8ebf11f23cc4a8245d1a8460775db8577d66c3456d4ca3aa9867",
11
- "packageJson": "99b5503dbc612740491b60a5d6281e7992bbc1ecb38c661716f6748e95a9100d",
10
+ "manifest": "6c9cbd0e9c74b8343090b38a49a93f94540f8dac86209264a4a9a484e0f14d1f",
11
+ "packageJson": "ac6df029fa84df8047004537889d034b050ea8beb97c99fc16f0b78b88eebb2e",
12
12
  "agents": "c4ab6a1aae24c0fb687d4d02ef25dcb5e6942ad7e8318e9d0dd8d03d5750b788",
13
13
  "moduleDoc:agents/permissions.md": "02b2f03f0e057721369d9c693a624a6fdb3df4935401531a4373ff18229a64be",
14
14
  "moduleDoc:agents/oidc-provisioning.md": "b73f3fdaf61136720132a614c7e14237b7bd35f7bf5d43eabb29f565485803b9",
@@ -7105,6 +7105,21 @@
7105
7105
  "readonly": true,
7106
7106
  "description": "The standardized email address used to recognize this account; maintained automatically."
7107
7107
  },
7108
+ {
7109
+ "name": "username",
7110
+ "type": "text",
7111
+ "required": false,
7112
+ "columnType": "TEXT",
7113
+ "description": "Optional username used to sign in; lowercase and globally unique."
7114
+ },
7115
+ {
7116
+ "name": "usernameKey",
7117
+ "type": "text",
7118
+ "required": false,
7119
+ "columnType": "TEXT",
7120
+ "readonly": true,
7121
+ "description": "The standardized username used to recognize this account; maintained automatically."
7122
+ },
7108
7123
  {
7109
7124
  "name": "status",
7110
7125
  "type": "text",
@@ -50,16 +50,28 @@
50
50
  */
51
51
  import '../__smrt-register__.js';
52
52
  import { PasswordCredentialService, type PasswordCredentialServiceOptions } from '../services/PasswordCredentialService.js';
53
+ /**
54
+ * Structural cookie subset. Options are always supplied by this module and
55
+ * match SvelteKit's required cookie path without making it a root dependency.
56
+ */
57
+ type CookieOptions = {
58
+ path: string;
59
+ domain?: string;
60
+ httpOnly?: boolean;
61
+ secure?: boolean;
62
+ sameSite?: 'strict' | 'lax' | 'none';
63
+ maxAge?: number;
64
+ };
53
65
  type Cookies = {
54
66
  get: (name: string) => string | undefined;
55
- set: (name: string, value: string, options?: Record<string, unknown>) => void;
56
- delete: (name: string, options?: Record<string, unknown>) => void;
67
+ set: (name: string, value: string, options: CookieOptions) => void;
68
+ delete: (name: string, options: CookieOptions) => void;
57
69
  };
58
70
  /** The parts of a SvelteKit `RequestEvent` these handlers use. */
59
71
  export type PasswordRequestEvent = {
60
72
  cookies: Cookies;
61
73
  getClientAddress?: () => string;
62
- locals?: Record<string, unknown>;
74
+ locals?: object;
63
75
  request: Request;
64
76
  url: URL;
65
77
  };
@@ -69,7 +81,7 @@ export interface CreatePasswordCredentialHandlersOptions extends PasswordCredent
69
81
  * it. A value or a per-request resolver. Null/omitted signs in with no
70
82
  * tenant context.
71
83
  */
72
- tenantId?: string | null | ((event: PasswordRequestEvent) => string | null | undefined | Promise<string | null | undefined>);
84
+ tenantId?: string | null | 'unique-active-membership' | ((event: PasswordRequestEvent) => string | null | undefined | 'unique-active-membership' | Promise<string | null | undefined | 'unique-active-membership'>);
73
85
  /** Session cookie name; must match `createSessionHandler`. Default `sid`. */
74
86
  cookieName?: string;
75
87
  cookiePath?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"password-handlers.d.ts","sourceRoot":"","sources":["../../src/sveltekit/password-handlers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAGH,OAAO,yBAAyB,CAAC;AAIjC,OAAO,EAGL,yBAAyB,EACzB,KAAK,gCAAgC,EAEtC,MAAM,0CAA0C,CAAC;AAKlD,KAAK,OAAO,GAAG;IACb,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;IAC1C,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;IAC9E,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;CACnE,CAAC;AAEF,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CAmJ5B"}
package/dist/sveltekit.js CHANGED
@@ -1,4 +1,4 @@
1
- import { A as withSessionPermissionContext, B as resolveOidcProviderConfig, C as OperationPermissionError, F as OidcLoginError, G as DeviceCredentialForbiddenError, I as OidcLoginService, K as DeviceCredentialPolicyError, L as decodeOidcTransaction, M as MobileAuthService, N as readMobileBearerToken, P as validateMobileRedirectUri, Q as SessionService, R as encodeOidcTransaction, W as DeviceCredentialError, _ as PasswordCredentialError, a as TerminalAuthError, b as PasswordPolicyError, j as MobileAuthError, lt as LoginRateLimitError, o as TerminalAuthRateLimitError, q as DeviceCredentialService, s as TerminalAuthService, v as PasswordCredentialForbiddenError, y as PasswordCredentialService, z as getUsersOidcConfig } from "./chunks/TerminalAuthService-BqdDnJ4T.js";
1
+ import { A as withSessionPermissionContext, B as resolveOidcProviderConfig, C as OperationPermissionError, F as OidcLoginError, G as DeviceCredentialForbiddenError, I as OidcLoginService, K as DeviceCredentialPolicyError, L as decodeOidcTransaction, M as MobileAuthService, N as readMobileBearerToken, P as validateMobileRedirectUri, Q as SessionService, R as encodeOidcTransaction, W as DeviceCredentialError, _ as PasswordCredentialError, a as TerminalAuthError, b as PasswordPolicyError, j as MobileAuthError, lt as LoginRateLimitError, o as TerminalAuthRateLimitError, q as DeviceCredentialService, s as TerminalAuthService, v as PasswordCredentialForbiddenError, y as PasswordCredentialService, z as getUsersOidcConfig } from "./chunks/TerminalAuthService-BpRwohDW.js";
2
2
  import { DiscoveryArtifactValidationError, SMRT_APP_RESULT_CONTRACT, SMRT_APP_RESULT_SCHEMA, SMRT_APP_RESULT_VERSION, SMRT_DISCOVERY_CONFORMANCE_ARTIFACT_SCHEMA, SMRT_DISCOVERY_CONFORMANCE_SCHEMA, SMRT_DISCOVERY_CONFORMANCE_VERSION, SMRT_MCP_RESULT_METADATA_KEY, canonicalizeDiscoveryArtifact, createDiscoveryConformanceArtifact, deriveCommandRequirements, validateDiscoveryConformanceArtifact } from "./app-contract.js";
3
3
  import { ObjectRegistry, createClassNamePredicate, resolveCustomActionMetadata, resolveEffectiveActionMetadata } from "@happyvertical/smrt-core";
4
4
  import { createLogger } from "@happyvertical/logger";