@bymax-one/nest-auth 1.2.0 → 1.3.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/CHANGELOG.md CHANGED
@@ -7,6 +7,47 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.3.0] - 2026-08-08
11
+
12
+ Minor rather than patch because the API now accepts a request it previously rejected: with a
13
+ `tenantIdResolver` configured, `tenantId` may be omitted from the body. Nothing a consumer sends
14
+ today stops working, and no option changed meaning.
15
+
16
+ ### Fixed
17
+
18
+ - **`tenantId` is optional on every DTO that carries it**, so a deployment that configures
19
+ `tenantIdResolver` no longer forces its clients to send a value the server discards. The
20
+ option's whole purpose is that the resolved tenant wins and the body's is ignored, but the nine
21
+ DTOs declared the field with `@IsString() @IsNotEmpty()` and no `@IsOptional()`, so a request
22
+ that omitted it was rejected before any service ran. The two configurations were both wrong in
23
+ opposite directions: without a resolver the body named the tenant and was trusted, and with one
24
+ the body was mandatory and ignored.
25
+
26
+ `resolveTenantId` now refuses a request that no resolver and no body value can scope, answering
27
+ `auth.validation` with the same `{ field, message }[]` shape the validation pipe produces. It is
28
+ refused rather than defaulted deliberately: inventing a tenant name would gather into one scope
29
+ every account a misconfigured deployment created. `null` counts as absent there, because
30
+ `@IsOptional()` skips validation for `null` as well as for `undefined` — a caller may send
31
+ `tenantId: null` past every DTO constraint, and admitting it would carry `null` into the
32
+ tenant-scoped lookups and into the Redis and HMAC keys built from it.
33
+
34
+ Nothing changes for a consumer that sends `tenantId` today, with or without a resolver.
35
+
36
+ - **`jwt.absoluteSessionLifetimeDays` is documented as the 30-day default it actually is.** The
37
+ option's doc comment, the README's option table, the README's "deliberately off by default"
38
+ note and the specification's table all still described the pre-1.2.0 behaviour, where the cap
39
+ was off unless a deployment asked for it. 1.2.0 turned it on at 30 days as a security fix and
40
+ the prose did not follow, so the surface a consumer reads in their editor argued for planning
41
+ around sessions that never end.
42
+
43
+ ### Changed
44
+
45
+ - `AuthService.register`, `AuthService.login`, `AuthService.verifyEmail`,
46
+ `AuthService.resendVerificationEmail` and `OAuthService.initiateOAuth` accept `tenantId` as
47
+ optional, matching the DTOs that feed them. The password-reset flows now read the resolved
48
+ tenant from the local binding rather than from the reassigned DTO, which is the same value and
49
+ removes the question of whether the reassignment happened.
50
+
10
51
  ## [1.2.0] - 2026-08-08
11
52
 
12
53
  Carries the third security audit and the findings that surfaced while driving the mutation
@@ -1152,7 +1193,8 @@ ever installable.
1152
1193
  - Phase 4 password-reset tests cover: both `token` and `otp` flows, mutual exclusivity validation, `verifiedToken` exchange, resend cooldown, anti-enumeration (no error on unknown email), and session invalidation on reset
1153
1194
  - Phase 5 tests cover: platform login with MFA path and brute-force lockout, `JwtPlatformGuard` cross-context rejection, `PlatformRolesGuard` hierarchy enforcement, OAuth CSRF state lifecycle, `onOAuthLogin` hook resolution strategies, and invitation role-authorization + acceptance single-use enforcement
1154
1195
 
1155
- [Unreleased]: https://github.com/bymaxone/nest-auth/compare/v1.2.0...HEAD
1196
+ [Unreleased]: https://github.com/bymaxone/nest-auth/compare/v1.3.0...HEAD
1197
+ [1.3.0]: https://github.com/bymaxone/nest-auth/compare/v1.2.0...v1.3.0
1156
1198
  [1.2.0]: https://github.com/bymaxone/nest-auth/compare/v1.1.1...v1.2.0
1157
1199
  [1.1.1]: https://github.com/bymaxone/nest-auth/compare/v1.1.0...v1.1.1
1158
1200
  [1.1.0]: https://github.com/bymaxone/nest-auth/compare/v1.0.11...v1.1.0
package/README.md CHANGED
@@ -644,25 +644,25 @@ both channels are accepted, and a ticket wins when both are present.
644
644
 
645
645
  All options are configurable via `registerAsync()`. Here are the key configuration groups:
646
646
 
647
- | Group | Key Options | Default |
648
- | --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------- |
649
- | **jwt** | `secret` (required), `previousSecrets`, `accessExpiresIn`, `refreshExpiresInDays`, `absoluteSessionLifetimeDays`, `algorithm`, `issuer`, `audience` | `15m`, `7d`, off, `HS256`, both off |
650
- | **environment** | `'production'` \| `'development'` \| `'test'` — the only input that answers "is this production" | `'production'` |
651
- | **password** | `minLength`, `costFactor`, `blockSize`, `parallelization` | `15`, scrypt N=2¹⁷, r=8, p=1 |
652
- | **tokenDelivery** | `'cookie'` \| `'bearer'` \| `'both'` | `'cookie'` |
653
- | **cookies** | `accessTokenName`, `refreshTokenName`, `sessionSignalName`, `refreshCookiePath`, `sameSite`, `trustedOrigins`, `resolveDomains` | `'lax'`, `[]` (see cookie section) |
654
- | **mfa** | `encryptionKey`, `previousEncryptionKeys`, `issuer`, `totpWindow`, `recoveryCodeCount` | — |
655
- | **sessions** | `enabled`, `defaultMaxSessions`, `maxSessionsResolver` | `false`, `5`, — |
656
- | **bruteForce** | `maxAttempts`, `windowSeconds` | `5`, `900` |
657
- | **rateLimit** | `enabled`, `clientIpSource` (`'peer'` \| `'trusted-proxy'`) — per-IP limits over Redis | `true`, **required** |
658
- | **passwordReset** | `method` (`'token'` \| `'otp'`), `otpLength`, `otpTtlSeconds` | `'token'` |
659
- | **platform** | `enabled` | `false` |
660
- | **invitations** | `enabled`, `tokenTtlSeconds` | `false` |
661
- | **roles** | `hierarchy` (required), `platformHierarchy` | — |
662
- | **oauth** | `google: { clientId, clientSecret, callbackUrl }` | — |
663
- | **emailVerification** | `required`, `otpTtlSeconds` | `true`, `600` |
664
- | **password** (screen) | `blocklist` — extra words the default screen refuses, on top of the ones it ships | `[]` |
665
- | **controllers** | Toggle individual controllers on/off | `auth`, `passwordReset` on; rest opt-in |
647
+ | Group | Key Options | Default |
648
+ | --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------- |
649
+ | **jwt** | `secret` (required), `previousSecrets`, `accessExpiresIn`, `refreshExpiresInDays`, `absoluteSessionLifetimeDays`, `algorithm`, `issuer`, `audience` | `15m`, `7d`, `30d` cap, `HS256`, both off |
650
+ | **environment** | `'production'` \| `'development'` \| `'test'` — the only input that answers "is this production" | `'production'` |
651
+ | **password** | `minLength`, `costFactor`, `blockSize`, `parallelization` | `15`, scrypt N=2¹⁷, r=8, p=1 |
652
+ | **tokenDelivery** | `'cookie'` \| `'bearer'` \| `'both'` | `'cookie'` |
653
+ | **cookies** | `accessTokenName`, `refreshTokenName`, `sessionSignalName`, `refreshCookiePath`, `sameSite`, `trustedOrigins`, `resolveDomains` | `'lax'`, `[]` (see cookie section) |
654
+ | **mfa** | `encryptionKey`, `previousEncryptionKeys`, `issuer`, `totpWindow`, `recoveryCodeCount` | — |
655
+ | **sessions** | `enabled`, `defaultMaxSessions`, `maxSessionsResolver` | `false`, `5`, — |
656
+ | **bruteForce** | `maxAttempts`, `windowSeconds` | `5`, `900` |
657
+ | **rateLimit** | `enabled`, `clientIpSource` (`'peer'` \| `'trusted-proxy'`) — per-IP limits over Redis | `true`, **required** |
658
+ | **passwordReset** | `method` (`'token'` \| `'otp'`), `otpLength`, `otpTtlSeconds` | `'token'` |
659
+ | **platform** | `enabled` | `false` |
660
+ | **invitations** | `enabled`, `tokenTtlSeconds` | `false` |
661
+ | **roles** | `hierarchy` (required), `platformHierarchy` | — |
662
+ | **oauth** | `google: { clientId, clientSecret, callbackUrl }` | — |
663
+ | **emailVerification** | `required`, `otpTtlSeconds` | `true`, `600` |
664
+ | **password** (screen) | `blocklist` — extra words the default screen refuses, on top of the ones it ships | `[]` |
665
+ | **controllers** | Toggle individual controllers on/off | `auth`, `passwordReset` on; rest opt-in |
666
666
 
667
667
  > [!NOTE]
668
668
  > When a feature is not configured (e.g., `mfa`, `sessions`, `platform`), its controllers and services are **not registered** in the NestJS container — zero overhead.
@@ -765,14 +765,22 @@ All options are configurable via `registerAsync()`. Here are the key configurati
765
765
  > rather than letting it fail open, and rejects an unreadable time span or a non-positive
766
766
  > lifetime on the same pass.
767
767
 
768
- Two options are deliberately off by default because switching them on changes behaviour for
769
- sessions and origins that already exist:
770
-
771
- - `jwt.absoluteSessionLifetimeDays` caps how long one login can be extended by rotation. Without
772
- it, a client refreshing every fifteen minutes keeps a session alive forever.
773
- - `cookies.trustedOrigins` is required as soon as `cookies.sameSite: 'none'` is set, and refused
774
- otherwise — that posture is the only one where the browser sends the session cookie
775
- cross-site, and it is the only one where the origin check has anything to authorize.
768
+ `jwt.absoluteSessionLifetimeDays` caps how long one login can be extended by rotation, and is
769
+ **on by default at 30 days** — NIST SP 800-63B-4 §3 makes a definite reauthentication timeout a
770
+ SHALL and puts it at no more than 30 days for AAL1. Without a cap, a client refreshing every
771
+ fifteen minutes keeps a session alive forever, and a refresh token stolen once becomes permanent
772
+ access. Raise it to a value the product can justify, or set `0` to accept unbounded sessions
773
+ deliberately.
774
+
775
+ Lowering the value ends sessions that are already older than the new one, at their next rotation;
776
+ raising it or setting `0` ends nothing. Sessions established before the cap existed carry no
777
+ recorded birth time and are never capped, whatever the value — they age out under
778
+ `refreshExpiresInDays` like any other.
779
+
780
+ `cookies.trustedOrigins` is deliberately off by default, because switching it on changes
781
+ behaviour for origins that already exist. It is required as soon as `cookies.sameSite: 'none'`
782
+ is set, and refused otherwise — that posture is the only one where the browser sends the session
783
+ cookie cross-site, and it is the only one where the origin check has anything to authorize.
776
784
 
777
785
  The breach check is opt-in for a different reason: it is the only part of the credential path
778
786
  that reaches the network, and a library should not start talking to a third party because it was
@@ -1186,6 +1186,7 @@ _ts_decorate([
1186
1186
  _ts_metadata("design:type", String)
1187
1187
  ], LoginDto.prototype, "password", void 0);
1188
1188
  _ts_decorate([
1189
+ classValidator.IsOptional(),
1189
1190
  classValidator.IsString(),
1190
1191
  classValidator.IsNotEmpty(),
1191
1192
  classValidator.MaxLength(128),
@@ -1267,6 +1268,7 @@ _ts_decorate2([
1267
1268
  _ts_metadata2("design:type", String)
1268
1269
  ], RegisterDto.prototype, "name", void 0);
1269
1270
  _ts_decorate2([
1271
+ classValidator.IsOptional(),
1270
1272
  classValidator.IsString(),
1271
1273
  classValidator.IsNotEmpty(),
1272
1274
  classValidator.MaxLength(128),
@@ -1307,6 +1309,7 @@ _ts_decorate3([
1307
1309
  _ts_metadata3("design:type", String)
1308
1310
  ], ResendVerificationDto.prototype, "email", void 0);
1309
1311
  _ts_decorate3([
1312
+ classValidator.IsOptional(),
1310
1313
  classValidator.IsString(),
1311
1314
  classValidator.IsNotEmpty(),
1312
1315
  classValidator.MaxLength(128),
@@ -1358,6 +1361,7 @@ _ts_decorate4([
1358
1361
  _ts_metadata4("design:type", String)
1359
1362
  ], VerifyEmailDto.prototype, "otp", void 0);
1360
1363
  _ts_decorate4([
1364
+ classValidator.IsOptional(),
1361
1365
  classValidator.IsString(),
1362
1366
  classValidator.IsNotEmpty(),
1363
1367
  classValidator.MaxLength(128),
@@ -5378,12 +5382,18 @@ function normalizeEmail(email) {
5378
5382
  return email.trim().toLowerCase();
5379
5383
  }
5380
5384
  __name(normalizeEmail, "normalizeEmail");
5381
-
5382
- // src/server/utils/resolve-tenant-id.ts
5383
5385
  async function resolveTenantId(dtoTenantId, req, resolver) {
5384
5386
  if (resolver) {
5385
5387
  return await resolver(req);
5386
5388
  }
5389
+ if (dtoTenantId === void 0 || dtoTenantId === null) {
5390
+ throw new AuthException(AUTH_ERROR_CODES.VALIDATION, common.HttpStatus.BAD_REQUEST, [
5391
+ {
5392
+ field: "tenantId",
5393
+ message: "tenantId is required unless the deployment configures tenantIdResolver"
5394
+ }
5395
+ ]);
5396
+ }
5387
5397
  return dtoTenantId;
5388
5398
  }
5389
5399
  __name(resolveTenantId, "resolveTenantId");
@@ -9440,6 +9450,7 @@ _ts_decorate37([
9440
9450
  _ts_metadata36("design:type", String)
9441
9451
  ], ForgotPasswordDto.prototype, "email", void 0);
9442
9452
  _ts_decorate37([
9453
+ classValidator.IsOptional(),
9443
9454
  classValidator.IsString(),
9444
9455
  classValidator.IsNotEmpty(),
9445
9456
  classValidator.MaxLength(128),
@@ -9480,6 +9491,7 @@ _ts_decorate38([
9480
9491
  _ts_metadata37("design:type", String)
9481
9492
  ], ResendOtpDto.prototype, "email", void 0);
9482
9493
  _ts_decorate38([
9494
+ classValidator.IsOptional(),
9483
9495
  classValidator.IsString(),
9484
9496
  classValidator.IsNotEmpty(),
9485
9497
  classValidator.MaxLength(128),
@@ -9577,6 +9589,7 @@ _ts_decorate39([
9577
9589
  _ts_metadata38("design:type", String)
9578
9590
  ], ResetPasswordDto.prototype, "verifiedToken", void 0);
9579
9591
  _ts_decorate39([
9592
+ classValidator.IsOptional(),
9580
9593
  classValidator.IsString(),
9581
9594
  classValidator.IsNotEmpty(),
9582
9595
  classValidator.MaxLength(128),
@@ -9629,6 +9642,7 @@ _ts_decorate40([
9629
9642
  _ts_metadata39("design:type", String)
9630
9643
  ], VerifyOtpDto.prototype, "otp", void 0);
9631
9644
  _ts_decorate40([
9645
+ classValidator.IsOptional(),
9632
9646
  classValidator.IsString(),
9633
9647
  classValidator.IsNotEmpty(),
9634
9648
  classValidator.MaxLength(128),
@@ -9714,20 +9728,20 @@ exports.PasswordResetService = class _PasswordResetService {
9714
9728
  email: normalizeEmail(dto.email)
9715
9729
  };
9716
9730
  const start = Date.now();
9717
- const cooldownKey = `resend:${PASSWORD_RESET_PURPOSE}:${this.otpIdentifier(dto.tenantId, dto.email)}`;
9731
+ const cooldownKey = `resend:${PASSWORD_RESET_PURPOSE}:${this.otpIdentifier(tenantId, dto.email)}`;
9718
9732
  const wasSet = await this.redis.setnx(cooldownKey, RESEND_COOLDOWN_SECONDS);
9719
9733
  if (!wasSet) {
9720
9734
  await sleep(Math.max(0, ANTI_ENUM_MIN_MS2 - (Date.now() - start)));
9721
9735
  return;
9722
9736
  }
9723
9737
  try {
9724
- const user = tenantScoped(await this.userRepo.findByEmail(dto.email, dto.tenantId), dto.tenantId);
9738
+ const user = tenantScoped(await this.userRepo.findByEmail(dto.email, tenantId), tenantId);
9725
9739
  if (user && !this.isBlocked(user.status)) {
9726
9740
  const { method } = this.options.passwordReset;
9727
9741
  if (method === "otp") {
9728
- await this.sendOtp(dto.email, dto.tenantId, user.id);
9742
+ await this.sendOtp(dto.email, tenantId, user.id);
9729
9743
  } else {
9730
- await this.sendToken(dto.email, dto.tenantId, user.id);
9744
+ await this.sendToken(dto.email, tenantId, user.id);
9731
9745
  }
9732
9746
  }
9733
9747
  } catch (err) {
@@ -9777,18 +9791,18 @@ exports.PasswordResetService = class _PasswordResetService {
9777
9791
  if (!dto.token) {
9778
9792
  throw new AuthException(AUTH_ERROR_CODES.PASSWORD_RESET_TOKEN_INVALID);
9779
9793
  }
9780
- await this.resetWithToken(dto.email, dto.tenantId, dto.token, dto.newPassword);
9794
+ await this.resetWithToken(dto.email, tenantId, dto.token, dto.newPassword);
9781
9795
  return;
9782
9796
  }
9783
9797
  if (dto.token) {
9784
9798
  throw new AuthException(AUTH_ERROR_CODES.PASSWORD_RESET_TOKEN_INVALID);
9785
9799
  }
9786
9800
  if (dto.verifiedToken) {
9787
- await this.resetWithVerifiedToken(dto.email, dto.tenantId, dto.verifiedToken, dto.newPassword);
9801
+ await this.resetWithVerifiedToken(dto.email, tenantId, dto.verifiedToken, dto.newPassword);
9788
9802
  return;
9789
9803
  }
9790
9804
  if (dto.otp) {
9791
- await this.resetWithOtp(dto.email, dto.tenantId, dto.otp, dto.newPassword);
9805
+ await this.resetWithOtp(dto.email, tenantId, dto.otp, dto.newPassword);
9792
9806
  return;
9793
9807
  }
9794
9808
  throw new AuthException(AUTH_ERROR_CODES.PASSWORD_RESET_TOKEN_INVALID);
@@ -9817,9 +9831,9 @@ exports.PasswordResetService = class _PasswordResetService {
9817
9831
  tenantId,
9818
9832
  email: normalizeEmail(dto.email)
9819
9833
  };
9820
- const identifier = this.otpIdentifier(dto.tenantId, dto.email);
9834
+ const identifier = this.otpIdentifier(tenantId, dto.email);
9821
9835
  await this.otpService.verify(PASSWORD_RESET_PURPOSE, identifier, dto.otp);
9822
- const user = tenantScoped(await this.userRepo.findByEmail(dto.email, dto.tenantId), dto.tenantId);
9836
+ const user = tenantScoped(await this.userRepo.findByEmail(dto.email, tenantId), tenantId);
9823
9837
  if (!user) {
9824
9838
  throw new AuthException(AUTH_ERROR_CODES.PASSWORD_RESET_TOKEN_INVALID);
9825
9839
  }
@@ -9827,7 +9841,7 @@ exports.PasswordResetService = class _PasswordResetService {
9827
9841
  const context = {
9828
9842
  userId: user.id,
9829
9843
  email: dto.email,
9830
- tenantId: dto.tenantId,
9844
+ tenantId,
9831
9845
  passwordFingerprint: await this.passwordFingerprintOf(user.id)
9832
9846
  };
9833
9847
  await this.redis.set(`pw_vtok:${sha256(rawVerifiedToken)}`, JSON.stringify(context), VERIFIED_TOKEN_TTL_SECONDS);
@@ -9852,7 +9866,7 @@ exports.PasswordResetService = class _PasswordResetService {
9852
9866
  email: normalizeEmail(dto.email)
9853
9867
  };
9854
9868
  const start = Date.now();
9855
- const identifier = this.otpIdentifier(dto.tenantId, dto.email);
9869
+ const identifier = this.otpIdentifier(tenantId, dto.email);
9856
9870
  const cooldownKey = `resend:${PASSWORD_RESET_PURPOSE}:${identifier}`;
9857
9871
  const wasSet = await this.redis.setnx(cooldownKey, RESEND_COOLDOWN_SECONDS);
9858
9872
  if (!wasSet) {
@@ -9860,9 +9874,9 @@ exports.PasswordResetService = class _PasswordResetService {
9860
9874
  return;
9861
9875
  }
9862
9876
  try {
9863
- const user = tenantScoped(await this.userRepo.findByEmail(dto.email, dto.tenantId), dto.tenantId);
9877
+ const user = tenantScoped(await this.userRepo.findByEmail(dto.email, tenantId), tenantId);
9864
9878
  if (user && !this.isBlocked(user.status)) {
9865
- await this.sendOtp(dto.email, dto.tenantId, user.id);
9879
+ await this.sendOtp(dto.email, tenantId, user.id);
9866
9880
  }
9867
9881
  } catch (err) {
9868
9882
  this.logger.error("resendOtp: unexpected error", err);
@@ -12112,6 +12126,7 @@ var OAuthInitiateQueryDto = class {
12112
12126
  tenantId;
12113
12127
  };
12114
12128
  _ts_decorate55([
12129
+ classValidator.IsOptional(),
12115
12130
  classValidator.IsString(),
12116
12131
  classValidator.IsNotEmpty(),
12117
12132
  classValidator.MaxLength(128),
@@ -426,7 +426,7 @@ interface BymaxAuthModuleOptions {
426
426
  refreshExpiresInDays?: number;
427
427
  /**
428
428
  * Hard cap on how long one login can be extended by rotation, in days.
429
- * Default: `0` — no cap.
429
+ * Default: `30`. Set to `0` to disable the cap.
430
430
  *
431
431
  * `refreshExpiresInDays` bounds how long a single refresh token lives, not how long a
432
432
  * *session* lives: a client that rotates every fifteen minutes renews that lifetime
@@ -435,9 +435,12 @@ interface BymaxAuthModuleOptions {
435
435
  * carried through every rotation, and once the cap is passed the rotation is refused and
436
436
  * the user signs in again.
437
437
  *
438
- * Left off by default because switching it on ends sessions that are already older than
439
- * the cap. Pick a value the product can justify asking a user to re-authenticate at (30
440
- * or 90 days are common), and set it deliberately.
438
+ * On by default at 30 days, because NIST SP 800-63B-4 §3 makes a definite reauthentication
439
+ * timeout a SHALL and puts it at no more than 30 days for AAL1. Without the cap a refresh
440
+ * token stolen once converts into permanent access: reuse detection only fires if the
441
+ * legitimate client also replays, which it never will once the victim has stopped using
442
+ * that device. Raise it to a value the product can justify asking a user to re-authenticate
443
+ * at, or set `0` to accept unbounded sessions deliberately.
441
444
  *
442
445
  * Sessions written before this existed carry no birth time and are not capped; they age
443
446
  * out under `refreshExpiresInDays` like any other.
@@ -1063,6 +1066,12 @@ interface BymaxAuthModuleOptions {
1063
1066
  * **ignores** any `tenantId` field in the request body. This prevents tenant
1064
1067
  * spoofing where a client sends a different tenant's ID.
1065
1068
  *
1069
+ * Because a configured resolver makes the body's value dead weight, `tenantId` is optional on
1070
+ * every DTO that carries it and a client may omit it entirely. With no resolver configured the
1071
+ * body is the only thing that can name a tenant, and a request naming none is refused with
1072
+ * `auth.validation` — the deployment has to choose one of the two, and neither choice is
1073
+ * guessed on its behalf.
1074
+ *
1066
1075
  * @param req - The Express request object
1067
1076
  * @returns The tenant ID string, or a Promise resolving to it
1068
1077
  *
@@ -5130,7 +5139,7 @@ declare class ForgotPasswordDto {
5130
5139
  /**
5131
5140
  * Tenant identifier that scopes the reset request to a specific organization.
5132
5141
  */
5133
- tenantId: string;
5142
+ tenantId?: string;
5134
5143
  }
5135
5144
 
5136
5145
  /**
@@ -5174,7 +5183,7 @@ declare class LoginDto {
5174
5183
  * Bounded to 128 characters — tenant IDs are part of HMAC pre-images and
5175
5184
  * Redis keys, so an unbounded string is rejected at the boundary.
5176
5185
  */
5177
- tenantId: string;
5186
+ tenantId?: string;
5178
5187
  }
5179
5188
 
5180
5189
  /**
@@ -5374,7 +5383,7 @@ declare class RegisterDto {
5374
5383
  * Tenant identifier that scopes the new user to a specific organization.
5375
5384
  * Bounded to 128 characters — part of HMAC pre-images and Redis keys.
5376
5385
  */
5377
- tenantId: string;
5386
+ tenantId?: string;
5378
5387
  }
5379
5388
 
5380
5389
  /**
@@ -5396,7 +5405,7 @@ declare class ResendOtpDto {
5396
5405
  /**
5397
5406
  * Tenant identifier that scopes the resend request to a specific organization.
5398
5407
  */
5399
- tenantId: string;
5408
+ tenantId?: string;
5400
5409
  }
5401
5410
 
5402
5411
  /**
@@ -5417,7 +5426,7 @@ declare class ResendVerificationDto {
5417
5426
  /**
5418
5427
  * Tenant identifier that scopes the resend request to a specific organization.
5419
5428
  */
5420
- tenantId: string;
5429
+ tenantId?: string;
5421
5430
  }
5422
5431
 
5423
5432
  /**
@@ -5516,7 +5525,7 @@ declare class ResetPasswordDto {
5516
5525
  * Validated against the stored tenant in the verifiedToken flow to prevent
5517
5526
  * cross-tenant password reset attacks.
5518
5527
  */
5519
- tenantId: string;
5528
+ tenantId?: string;
5520
5529
  }
5521
5530
 
5522
5531
  /**
@@ -5542,7 +5551,7 @@ declare class VerifyEmailDto {
5542
5551
  /**
5543
5552
  * Tenant identifier that scopes the verification to a specific organization.
5544
5553
  */
5545
- tenantId: string;
5554
+ tenantId?: string;
5546
5555
  }
5547
5556
 
5548
5557
  /**
@@ -5570,7 +5579,7 @@ declare class VerifyOtpDto {
5570
5579
  /**
5571
5580
  * Tenant identifier that scopes the verification to a specific organization.
5572
5581
  */
5573
- tenantId: string;
5582
+ tenantId?: string;
5574
5583
  }
5575
5584
 
5576
5585
  /**
@@ -6607,7 +6616,7 @@ declare class AuthService {
6607
6616
  email: string;
6608
6617
  password: string;
6609
6618
  name: string;
6610
- tenantId: string;
6619
+ tenantId?: string;
6611
6620
  }, req: Request): Promise<AuthResult>;
6612
6621
  /**
6613
6622
  * Authenticates a dashboard user with email and password.
@@ -6624,7 +6633,7 @@ declare class AuthService {
6624
6633
  login(dto: {
6625
6634
  email: string;
6626
6635
  password: string;
6627
- tenantId: string;
6636
+ tenantId?: string;
6628
6637
  }, req: Request): Promise<AuthResult | MfaChallengeResult>;
6629
6638
  /**
6630
6639
  * Logs out a dashboard user by revoking the access token and deleting the refresh session.
@@ -6751,7 +6760,7 @@ declare class AuthService {
6751
6760
  * or the user does not exist (response shape is identical to prevent
6752
6761
  * account enumeration via this endpoint).
6753
6762
  */
6754
- verifyEmail(tenantId: string, email: string, otp: string, req: Request): Promise<void>;
6763
+ verifyEmail(tenantId: string | undefined, email: string, otp: string, req: Request): Promise<void>;
6755
6764
  /**
6756
6765
  * Resends an email verification OTP with an atomic cooldown.
6757
6766
  *
@@ -6762,7 +6771,7 @@ declare class AuthService {
6762
6771
  * @param tenantId - Tenant scope.
6763
6772
  * @param email - The email address to re-send to (not validated — always succeeds).
6764
6773
  */
6765
- resendVerificationEmail(tenantId: string, email: string, req: Request): Promise<void>;
6774
+ resendVerificationEmail(tenantId: string | undefined, email: string, req: Request): Promise<void>;
6766
6775
  /**
6767
6776
  * Clears an account's brute-force lockout so the next attempt is judged on its merits.
6768
6777
  *
@@ -8127,7 +8136,7 @@ declare class OAuthService {
8127
8136
  * @param res - Express response in passthrough mode (used for the 302 redirect).
8128
8137
  * @throws `AuthException(OAUTH_FAILED)` when no plugin is registered for `provider`.
8129
8138
  */
8130
- initiateOAuth(provider: string, tenantId: string, req: Request, res: Response): Promise<void>;
8139
+ initiateOAuth(provider: string, tenantId: string | undefined, req: Request, res: Response): Promise<void>;
8131
8140
  /**
8132
8141
  * Processes the OAuth provider callback and issues auth tokens.
8133
8142
  *
@@ -426,7 +426,7 @@ interface BymaxAuthModuleOptions {
426
426
  refreshExpiresInDays?: number;
427
427
  /**
428
428
  * Hard cap on how long one login can be extended by rotation, in days.
429
- * Default: `0` — no cap.
429
+ * Default: `30`. Set to `0` to disable the cap.
430
430
  *
431
431
  * `refreshExpiresInDays` bounds how long a single refresh token lives, not how long a
432
432
  * *session* lives: a client that rotates every fifteen minutes renews that lifetime
@@ -435,9 +435,12 @@ interface BymaxAuthModuleOptions {
435
435
  * carried through every rotation, and once the cap is passed the rotation is refused and
436
436
  * the user signs in again.
437
437
  *
438
- * Left off by default because switching it on ends sessions that are already older than
439
- * the cap. Pick a value the product can justify asking a user to re-authenticate at (30
440
- * or 90 days are common), and set it deliberately.
438
+ * On by default at 30 days, because NIST SP 800-63B-4 §3 makes a definite reauthentication
439
+ * timeout a SHALL and puts it at no more than 30 days for AAL1. Without the cap a refresh
440
+ * token stolen once converts into permanent access: reuse detection only fires if the
441
+ * legitimate client also replays, which it never will once the victim has stopped using
442
+ * that device. Raise it to a value the product can justify asking a user to re-authenticate
443
+ * at, or set `0` to accept unbounded sessions deliberately.
441
444
  *
442
445
  * Sessions written before this existed carry no birth time and are not capped; they age
443
446
  * out under `refreshExpiresInDays` like any other.
@@ -1063,6 +1066,12 @@ interface BymaxAuthModuleOptions {
1063
1066
  * **ignores** any `tenantId` field in the request body. This prevents tenant
1064
1067
  * spoofing where a client sends a different tenant's ID.
1065
1068
  *
1069
+ * Because a configured resolver makes the body's value dead weight, `tenantId` is optional on
1070
+ * every DTO that carries it and a client may omit it entirely. With no resolver configured the
1071
+ * body is the only thing that can name a tenant, and a request naming none is refused with
1072
+ * `auth.validation` — the deployment has to choose one of the two, and neither choice is
1073
+ * guessed on its behalf.
1074
+ *
1066
1075
  * @param req - The Express request object
1067
1076
  * @returns The tenant ID string, or a Promise resolving to it
1068
1077
  *
@@ -5130,7 +5139,7 @@ declare class ForgotPasswordDto {
5130
5139
  /**
5131
5140
  * Tenant identifier that scopes the reset request to a specific organization.
5132
5141
  */
5133
- tenantId: string;
5142
+ tenantId?: string;
5134
5143
  }
5135
5144
 
5136
5145
  /**
@@ -5174,7 +5183,7 @@ declare class LoginDto {
5174
5183
  * Bounded to 128 characters — tenant IDs are part of HMAC pre-images and
5175
5184
  * Redis keys, so an unbounded string is rejected at the boundary.
5176
5185
  */
5177
- tenantId: string;
5186
+ tenantId?: string;
5178
5187
  }
5179
5188
 
5180
5189
  /**
@@ -5374,7 +5383,7 @@ declare class RegisterDto {
5374
5383
  * Tenant identifier that scopes the new user to a specific organization.
5375
5384
  * Bounded to 128 characters — part of HMAC pre-images and Redis keys.
5376
5385
  */
5377
- tenantId: string;
5386
+ tenantId?: string;
5378
5387
  }
5379
5388
 
5380
5389
  /**
@@ -5396,7 +5405,7 @@ declare class ResendOtpDto {
5396
5405
  /**
5397
5406
  * Tenant identifier that scopes the resend request to a specific organization.
5398
5407
  */
5399
- tenantId: string;
5408
+ tenantId?: string;
5400
5409
  }
5401
5410
 
5402
5411
  /**
@@ -5417,7 +5426,7 @@ declare class ResendVerificationDto {
5417
5426
  /**
5418
5427
  * Tenant identifier that scopes the resend request to a specific organization.
5419
5428
  */
5420
- tenantId: string;
5429
+ tenantId?: string;
5421
5430
  }
5422
5431
 
5423
5432
  /**
@@ -5516,7 +5525,7 @@ declare class ResetPasswordDto {
5516
5525
  * Validated against the stored tenant in the verifiedToken flow to prevent
5517
5526
  * cross-tenant password reset attacks.
5518
5527
  */
5519
- tenantId: string;
5528
+ tenantId?: string;
5520
5529
  }
5521
5530
 
5522
5531
  /**
@@ -5542,7 +5551,7 @@ declare class VerifyEmailDto {
5542
5551
  /**
5543
5552
  * Tenant identifier that scopes the verification to a specific organization.
5544
5553
  */
5545
- tenantId: string;
5554
+ tenantId?: string;
5546
5555
  }
5547
5556
 
5548
5557
  /**
@@ -5570,7 +5579,7 @@ declare class VerifyOtpDto {
5570
5579
  /**
5571
5580
  * Tenant identifier that scopes the verification to a specific organization.
5572
5581
  */
5573
- tenantId: string;
5582
+ tenantId?: string;
5574
5583
  }
5575
5584
 
5576
5585
  /**
@@ -6607,7 +6616,7 @@ declare class AuthService {
6607
6616
  email: string;
6608
6617
  password: string;
6609
6618
  name: string;
6610
- tenantId: string;
6619
+ tenantId?: string;
6611
6620
  }, req: Request): Promise<AuthResult>;
6612
6621
  /**
6613
6622
  * Authenticates a dashboard user with email and password.
@@ -6624,7 +6633,7 @@ declare class AuthService {
6624
6633
  login(dto: {
6625
6634
  email: string;
6626
6635
  password: string;
6627
- tenantId: string;
6636
+ tenantId?: string;
6628
6637
  }, req: Request): Promise<AuthResult | MfaChallengeResult>;
6629
6638
  /**
6630
6639
  * Logs out a dashboard user by revoking the access token and deleting the refresh session.
@@ -6751,7 +6760,7 @@ declare class AuthService {
6751
6760
  * or the user does not exist (response shape is identical to prevent
6752
6761
  * account enumeration via this endpoint).
6753
6762
  */
6754
- verifyEmail(tenantId: string, email: string, otp: string, req: Request): Promise<void>;
6763
+ verifyEmail(tenantId: string | undefined, email: string, otp: string, req: Request): Promise<void>;
6755
6764
  /**
6756
6765
  * Resends an email verification OTP with an atomic cooldown.
6757
6766
  *
@@ -6762,7 +6771,7 @@ declare class AuthService {
6762
6771
  * @param tenantId - Tenant scope.
6763
6772
  * @param email - The email address to re-send to (not validated — always succeeds).
6764
6773
  */
6765
- resendVerificationEmail(tenantId: string, email: string, req: Request): Promise<void>;
6774
+ resendVerificationEmail(tenantId: string | undefined, email: string, req: Request): Promise<void>;
6766
6775
  /**
6767
6776
  * Clears an account's brute-force lockout so the next attempt is judged on its merits.
6768
6777
  *
@@ -8127,7 +8136,7 @@ declare class OAuthService {
8127
8136
  * @param res - Express response in passthrough mode (used for the 302 redirect).
8128
8137
  * @throws `AuthException(OAUTH_FAILED)` when no plugin is registered for `provider`.
8129
8138
  */
8130
- initiateOAuth(provider: string, tenantId: string, req: Request, res: Response): Promise<void>;
8139
+ initiateOAuth(provider: string, tenantId: string | undefined, req: Request, res: Response): Promise<void>;
8131
8140
  /**
8132
8141
  * Processes the OAuth provider callback and issues auth tokens.
8133
8142
  *
@@ -3,7 +3,7 @@ import { JwtService, JwtModule } from '@nestjs/jwt';
3
3
  import { randomInt, scrypt as scrypt$1, randomBytes, timingSafeEqual, randomUUID, createHash, createHmac, createCipheriv, createDecipheriv } from 'crypto';
4
4
  import { Throttle } from '@nestjs/throttler';
5
5
  import { Transform } from 'class-transformer';
6
- import { IsEmail, MaxLength, IsString, MinLength, IsNotEmpty, Matches, Length, IsOptional, ValidateIf } from 'class-validator';
6
+ import { IsEmail, MaxLength, IsString, MinLength, IsOptional, IsNotEmpty, Matches, Length, ValidateIf } from 'class-validator';
7
7
  import { Reflector } from '@nestjs/core';
8
8
  import { isIPv6 } from 'net';
9
9
  import { promisify } from 'util';
@@ -1184,6 +1184,7 @@ _ts_decorate([
1184
1184
  _ts_metadata("design:type", String)
1185
1185
  ], LoginDto.prototype, "password", void 0);
1186
1186
  _ts_decorate([
1187
+ IsOptional(),
1187
1188
  IsString(),
1188
1189
  IsNotEmpty(),
1189
1190
  MaxLength(128),
@@ -1265,6 +1266,7 @@ _ts_decorate2([
1265
1266
  _ts_metadata2("design:type", String)
1266
1267
  ], RegisterDto.prototype, "name", void 0);
1267
1268
  _ts_decorate2([
1269
+ IsOptional(),
1268
1270
  IsString(),
1269
1271
  IsNotEmpty(),
1270
1272
  MaxLength(128),
@@ -1305,6 +1307,7 @@ _ts_decorate3([
1305
1307
  _ts_metadata3("design:type", String)
1306
1308
  ], ResendVerificationDto.prototype, "email", void 0);
1307
1309
  _ts_decorate3([
1310
+ IsOptional(),
1308
1311
  IsString(),
1309
1312
  IsNotEmpty(),
1310
1313
  MaxLength(128),
@@ -1356,6 +1359,7 @@ _ts_decorate4([
1356
1359
  _ts_metadata4("design:type", String)
1357
1360
  ], VerifyEmailDto.prototype, "otp", void 0);
1358
1361
  _ts_decorate4([
1362
+ IsOptional(),
1359
1363
  IsString(),
1360
1364
  IsNotEmpty(),
1361
1365
  MaxLength(128),
@@ -5376,12 +5380,18 @@ function normalizeEmail(email) {
5376
5380
  return email.trim().toLowerCase();
5377
5381
  }
5378
5382
  __name(normalizeEmail, "normalizeEmail");
5379
-
5380
- // src/server/utils/resolve-tenant-id.ts
5381
5383
  async function resolveTenantId(dtoTenantId, req, resolver) {
5382
5384
  if (resolver) {
5383
5385
  return await resolver(req);
5384
5386
  }
5387
+ if (dtoTenantId === void 0 || dtoTenantId === null) {
5388
+ throw new AuthException(AUTH_ERROR_CODES.VALIDATION, HttpStatus.BAD_REQUEST, [
5389
+ {
5390
+ field: "tenantId",
5391
+ message: "tenantId is required unless the deployment configures tenantIdResolver"
5392
+ }
5393
+ ]);
5394
+ }
5385
5395
  return dtoTenantId;
5386
5396
  }
5387
5397
  __name(resolveTenantId, "resolveTenantId");
@@ -9438,6 +9448,7 @@ _ts_decorate37([
9438
9448
  _ts_metadata36("design:type", String)
9439
9449
  ], ForgotPasswordDto.prototype, "email", void 0);
9440
9450
  _ts_decorate37([
9451
+ IsOptional(),
9441
9452
  IsString(),
9442
9453
  IsNotEmpty(),
9443
9454
  MaxLength(128),
@@ -9478,6 +9489,7 @@ _ts_decorate38([
9478
9489
  _ts_metadata37("design:type", String)
9479
9490
  ], ResendOtpDto.prototype, "email", void 0);
9480
9491
  _ts_decorate38([
9492
+ IsOptional(),
9481
9493
  IsString(),
9482
9494
  IsNotEmpty(),
9483
9495
  MaxLength(128),
@@ -9575,6 +9587,7 @@ _ts_decorate39([
9575
9587
  _ts_metadata38("design:type", String)
9576
9588
  ], ResetPasswordDto.prototype, "verifiedToken", void 0);
9577
9589
  _ts_decorate39([
9590
+ IsOptional(),
9578
9591
  IsString(),
9579
9592
  IsNotEmpty(),
9580
9593
  MaxLength(128),
@@ -9627,6 +9640,7 @@ _ts_decorate40([
9627
9640
  _ts_metadata39("design:type", String)
9628
9641
  ], VerifyOtpDto.prototype, "otp", void 0);
9629
9642
  _ts_decorate40([
9643
+ IsOptional(),
9630
9644
  IsString(),
9631
9645
  IsNotEmpty(),
9632
9646
  MaxLength(128),
@@ -9712,20 +9726,20 @@ var PasswordResetService = class _PasswordResetService {
9712
9726
  email: normalizeEmail(dto.email)
9713
9727
  };
9714
9728
  const start = Date.now();
9715
- const cooldownKey = `resend:${PASSWORD_RESET_PURPOSE}:${this.otpIdentifier(dto.tenantId, dto.email)}`;
9729
+ const cooldownKey = `resend:${PASSWORD_RESET_PURPOSE}:${this.otpIdentifier(tenantId, dto.email)}`;
9716
9730
  const wasSet = await this.redis.setnx(cooldownKey, RESEND_COOLDOWN_SECONDS);
9717
9731
  if (!wasSet) {
9718
9732
  await sleep(Math.max(0, ANTI_ENUM_MIN_MS2 - (Date.now() - start)));
9719
9733
  return;
9720
9734
  }
9721
9735
  try {
9722
- const user = tenantScoped(await this.userRepo.findByEmail(dto.email, dto.tenantId), dto.tenantId);
9736
+ const user = tenantScoped(await this.userRepo.findByEmail(dto.email, tenantId), tenantId);
9723
9737
  if (user && !this.isBlocked(user.status)) {
9724
9738
  const { method } = this.options.passwordReset;
9725
9739
  if (method === "otp") {
9726
- await this.sendOtp(dto.email, dto.tenantId, user.id);
9740
+ await this.sendOtp(dto.email, tenantId, user.id);
9727
9741
  } else {
9728
- await this.sendToken(dto.email, dto.tenantId, user.id);
9742
+ await this.sendToken(dto.email, tenantId, user.id);
9729
9743
  }
9730
9744
  }
9731
9745
  } catch (err) {
@@ -9775,18 +9789,18 @@ var PasswordResetService = class _PasswordResetService {
9775
9789
  if (!dto.token) {
9776
9790
  throw new AuthException(AUTH_ERROR_CODES.PASSWORD_RESET_TOKEN_INVALID);
9777
9791
  }
9778
- await this.resetWithToken(dto.email, dto.tenantId, dto.token, dto.newPassword);
9792
+ await this.resetWithToken(dto.email, tenantId, dto.token, dto.newPassword);
9779
9793
  return;
9780
9794
  }
9781
9795
  if (dto.token) {
9782
9796
  throw new AuthException(AUTH_ERROR_CODES.PASSWORD_RESET_TOKEN_INVALID);
9783
9797
  }
9784
9798
  if (dto.verifiedToken) {
9785
- await this.resetWithVerifiedToken(dto.email, dto.tenantId, dto.verifiedToken, dto.newPassword);
9799
+ await this.resetWithVerifiedToken(dto.email, tenantId, dto.verifiedToken, dto.newPassword);
9786
9800
  return;
9787
9801
  }
9788
9802
  if (dto.otp) {
9789
- await this.resetWithOtp(dto.email, dto.tenantId, dto.otp, dto.newPassword);
9803
+ await this.resetWithOtp(dto.email, tenantId, dto.otp, dto.newPassword);
9790
9804
  return;
9791
9805
  }
9792
9806
  throw new AuthException(AUTH_ERROR_CODES.PASSWORD_RESET_TOKEN_INVALID);
@@ -9815,9 +9829,9 @@ var PasswordResetService = class _PasswordResetService {
9815
9829
  tenantId,
9816
9830
  email: normalizeEmail(dto.email)
9817
9831
  };
9818
- const identifier = this.otpIdentifier(dto.tenantId, dto.email);
9832
+ const identifier = this.otpIdentifier(tenantId, dto.email);
9819
9833
  await this.otpService.verify(PASSWORD_RESET_PURPOSE, identifier, dto.otp);
9820
- const user = tenantScoped(await this.userRepo.findByEmail(dto.email, dto.tenantId), dto.tenantId);
9834
+ const user = tenantScoped(await this.userRepo.findByEmail(dto.email, tenantId), tenantId);
9821
9835
  if (!user) {
9822
9836
  throw new AuthException(AUTH_ERROR_CODES.PASSWORD_RESET_TOKEN_INVALID);
9823
9837
  }
@@ -9825,7 +9839,7 @@ var PasswordResetService = class _PasswordResetService {
9825
9839
  const context = {
9826
9840
  userId: user.id,
9827
9841
  email: dto.email,
9828
- tenantId: dto.tenantId,
9842
+ tenantId,
9829
9843
  passwordFingerprint: await this.passwordFingerprintOf(user.id)
9830
9844
  };
9831
9845
  await this.redis.set(`pw_vtok:${sha256(rawVerifiedToken)}`, JSON.stringify(context), VERIFIED_TOKEN_TTL_SECONDS);
@@ -9850,7 +9864,7 @@ var PasswordResetService = class _PasswordResetService {
9850
9864
  email: normalizeEmail(dto.email)
9851
9865
  };
9852
9866
  const start = Date.now();
9853
- const identifier = this.otpIdentifier(dto.tenantId, dto.email);
9867
+ const identifier = this.otpIdentifier(tenantId, dto.email);
9854
9868
  const cooldownKey = `resend:${PASSWORD_RESET_PURPOSE}:${identifier}`;
9855
9869
  const wasSet = await this.redis.setnx(cooldownKey, RESEND_COOLDOWN_SECONDS);
9856
9870
  if (!wasSet) {
@@ -9858,9 +9872,9 @@ var PasswordResetService = class _PasswordResetService {
9858
9872
  return;
9859
9873
  }
9860
9874
  try {
9861
- const user = tenantScoped(await this.userRepo.findByEmail(dto.email, dto.tenantId), dto.tenantId);
9875
+ const user = tenantScoped(await this.userRepo.findByEmail(dto.email, tenantId), tenantId);
9862
9876
  if (user && !this.isBlocked(user.status)) {
9863
- await this.sendOtp(dto.email, dto.tenantId, user.id);
9877
+ await this.sendOtp(dto.email, tenantId, user.id);
9864
9878
  }
9865
9879
  } catch (err) {
9866
9880
  this.logger.error("resendOtp: unexpected error", err);
@@ -12110,6 +12124,7 @@ var OAuthInitiateQueryDto = class {
12110
12124
  tenantId;
12111
12125
  };
12112
12126
  _ts_decorate55([
12127
+ IsOptional(),
12113
12128
  IsString(),
12114
12129
  IsNotEmpty(),
12115
12130
  MaxLength(128),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bymax-one/nest-auth",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "Full-stack authentication and authorization package for NestJS, React and Next.js — JWT, MFA, OAuth, sessions, multi-tenant SaaS ready",
5
5
  "author": "Bymax One <support@bymax.one>",
6
6
  "license": "MIT",
@@ -84,7 +84,7 @@
84
84
  "lint": "eslint src",
85
85
  "lint:fix": "eslint src --fix",
86
86
  "mutation": "stryker run",
87
- "mutation:full": "node -e \"require('node:fs').rmSync('reports/stryker-incremental.json',{force:true})\" && stryker run",
87
+ "mutation:full": "node -e \"require('node:fs').rmSync('reports/stryker-incremental.json',{force:true,recursive:true})\" && stryker run",
88
88
  "mutation:dry-run": "stryker run --dryRunOnly",
89
89
  "prepare": "husky",
90
90
  "prepublishOnly": "pnpm clean && pnpm typecheck && pnpm lint && pnpm test:cov:all && pnpm build && pnpm size && pnpm check:exports && pnpm check:published && pnpm check:runtime",