@bymax-one/nest-auth 1.5.11 → 1.5.13
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 +111 -1
- package/README.md +4 -4
- package/dist/server/index.cjs +681 -66
- package/dist/server/index.d.cts +3 -4
- package/dist/server/index.d.ts +3 -4
- package/dist/server/index.mjs +682 -67
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -18,6 +18,114 @@ what moves, and that note is the compatibility contract until strict SemVer begi
|
|
|
18
18
|
|
|
19
19
|
## [Unreleased]
|
|
20
20
|
|
|
21
|
+
## [1.5.13] - 2026-11-21
|
|
22
|
+
|
|
23
|
+
A patch release.
|
|
24
|
+
|
|
25
|
+
### Fixed
|
|
26
|
+
|
|
27
|
+
- **A tenant is read as a string and as nothing else.** The `tenantId` of a user, a workspace and a membership was
|
|
28
|
+
accepted as a string or as any instance of a class of the host: a `Date`, a `Map`, an object that inherits from a
|
|
29
|
+
plain object, a class that only has `toString`. Comparisons with the tenant of a request already failed closed, but
|
|
30
|
+
the value is written into the claims of a token, where two tenants whose ids are objects both serialize to `{}`. Any
|
|
31
|
+
value that is not a string now ends as `auth.internal`. **Apply to a derived backend:** a repository that serves the
|
|
32
|
+
tenant as an object (an id type of a driver) has to serve it as a string.
|
|
33
|
+
- **The time of a real date is the time it holds.** A subclass of `Date` that overrides `getTime` was asked for its
|
|
34
|
+
time, so a host could name a deadline other than the one the date carries. A real date is read through
|
|
35
|
+
`Date.prototype.getTime`; a Proxy of a date, which has no slot, is still read through its own `getTime`.
|
|
36
|
+
- **A read follows a bounded number of nodes in all.** The cap of 100 000 elements or keys applied to each array and
|
|
37
|
+
each object, so a list of records that each stayed under it could still make a copy walk as many nodes as the host
|
|
38
|
+
served. A read now follows at most 1 000 000 nodes (the elements of lists, the own keys of records and the strings of
|
|
39
|
+
lists of strings); an answer that holds more ends as `auth.internal`.
|
|
40
|
+
- **Access to a workspace is refused when the repository answers with a row of another tenant.** The workspace and the
|
|
41
|
+
membership read for a tenant, a workspace and a user are now checked to carry the tenant that was asked about; the
|
|
42
|
+
key given to a repository is not a proof of the row it returned.
|
|
43
|
+
- **An id names one row, and the library keeps it as a string.** The ids of users, workspaces and memberships were
|
|
44
|
+
accepted as a string, a finite number or any instance of a class of the host, so a `Map` or a `Date` was an id, and
|
|
45
|
+
two of them printed the same in a claim, a key or the scope of a query. An id is now a non-empty string, a safe
|
|
46
|
+
integer, or an object of the host that prints as a non-empty text of its own, and what the library keeps is the text
|
|
47
|
+
it prints as, read once. A `Date`, a `RegExp`, a `Map`, a `Set`, a `Promise`, an array, a plain object, a function, a
|
|
48
|
+
boolean, a fraction, an integer past the safe range and an object that prints as nothing or as `[object ...]` end as
|
|
49
|
+
`auth.internal`. An account whose id is a number now works after the login: the token's subject was the number, which
|
|
50
|
+
the verifier refuses, so `/me`, a refresh and a password change answered 401 for an account that had just logged in.
|
|
51
|
+
**Apply to a derived backend:** the library hands the repository the id as a string (it always did, from the token),
|
|
52
|
+
so a repository keyed by a number has to accept the string; a repository that serves a numeric id as a fraction or
|
|
53
|
+
past 2^53 has to serve it as a string. A hook that receives a user now sees the id as its string form (a host
|
|
54
|
+
callback that receives the host's own entity, such as `maxSessionsResolver`, still gets the object as it was).
|
|
55
|
+
- **The secret that signs is the secret that was checked, and the role hierarchies are read once.** The signer is
|
|
56
|
+
configured by a second call of the host's options factory, and what that call answered was the secret that signed
|
|
57
|
+
and verified: a factory that answered a weak secret the second time passed the strength check on the first answer and
|
|
58
|
+
signed with the weak one. Every sign and every verify now names the secret the options resolved to. The role
|
|
59
|
+
hierarchies (`roles.hierarchy`, `roles.platformHierarchy` and `workspaces.roles.hierarchy`) were kept as the host's
|
|
60
|
+
own objects and read through its getters at every check; each is read once, as plain data, so a getter that answers
|
|
61
|
+
differently later cannot grant a role that was never validated. `roles`, `workspaces` and `workspaces.roles` must be objects: a
|
|
62
|
+
function, an array or a primitive given for one is refused with `[BymaxAuthModule] <option> must be an object
|
|
63
|
+
(received …)`, as the other option groups already were.
|
|
64
|
+
- **A resend of the verification code that fails gives the cooldown back.** The request took the one-minute cooldown
|
|
65
|
+
before it looked the account up, so a request that failed there (a repository that throws, or answers with a record the
|
|
66
|
+
copy refuses) left the retry it invites refused for the rest of the minute. A request that took the cooldown and failed
|
|
67
|
+
releases it, as the password reset request already did; a request that sent, or found the cooldown taken, keeps it.
|
|
68
|
+
|
|
69
|
+
## [1.5.12] - 2026-11-21
|
|
70
|
+
|
|
71
|
+
A patch release.
|
|
72
|
+
|
|
73
|
+
### Fixed
|
|
74
|
+
|
|
75
|
+
- **A host getter, Proxy or factory that throws no longer leaves the library as the host's own error.** The options a
|
|
76
|
+
host returns are read inside one boundary: a failure ends as `[BymaxAuthModule] the options could not be read…` with
|
|
77
|
+
the host's error as its `cause` and none of its text. Each repository the host provides is read through a guarded
|
|
78
|
+
view that the library's own services use: an answer is read for the fields its method promises and for nothing
|
|
79
|
+
else (a contract for each repository method, checked by the compiler), so an entity whose relation throws until it
|
|
80
|
+
is loaded still answers, a field the contract names that throws ends as `auth.internal` with the cause, and a failure
|
|
81
|
+
of the repository itself is the same error. A typed `HttpException` the repository throws goes out as it is. Any
|
|
82
|
+
other own data field of the host's record is passed on by reference without being read, host callbacks
|
|
83
|
+
(`maxSessionsResolver`) still receive the host's own entity, the token the module exports is still the host's own
|
|
84
|
+
instance, and `OAuthModule.register` used on its own provides its own guarded view.
|
|
85
|
+
- **A field that decides an admission is read as the kind its contract gives it.** The contract of each repository
|
|
86
|
+
method names, for every field, the kind of the type the interface declares, and the compiler checks it. The fields
|
|
87
|
+
a service reads to allow or to deny (`mfaEnabled`, `emailVerified`, `status`, `role`, the credentials, an
|
|
88
|
+
API key's `digest`, `scopes`, `expiresAt` and `revokedAt`, a workspace's `deletionScheduledAt`) are strict: a boolean
|
|
89
|
+
is a boolean and not a wrapper of one (`new Boolean(false)` is truthy), a string is a string, a date is a date with a
|
|
90
|
+
real time, a list of strings holds strings, and a field the interface requires is refused when a record lacks it. A
|
|
91
|
+
function, a symbol, a bigint or a wrapper there ends as `auth.internal` instead of being dropped as absent or
|
|
92
|
+
coerced: read as absent, `mfaEnabled` served as a function would have issued tokens where a second factor is due, and
|
|
93
|
+
a wrapper in `emailVerified` would have passed an unverified account. A field the interface allows to be absent may
|
|
94
|
+
be absent or `null`. The fields that only inform (an id, a name, the dates the library returns or displays) are
|
|
95
|
+
lenient: an id may be a string, a finite number or an instance of a class of the host (the id type of a driver, kept
|
|
96
|
+
as the host's own object), a date may be a date, a string, a number or an instance of another class (a date
|
|
97
|
+
library's), and absence is accepted; a function, a symbol, a bigint and the other values no reader lists are still
|
|
98
|
+
refused there. A method that owes a record, a page or a list and answers nothing ends as `auth.internal`; only a
|
|
99
|
+
lookup that may find nothing passes the nothing on.
|
|
100
|
+
- **A date a host wraps in a Proxy is read as a date.** A valid API key whose `expiresAt` was a Proxy of a `Date` was
|
|
101
|
+
refused, and a workspace whose `deletionScheduledAt` was one could be neither restored nor finalized, because the copy
|
|
102
|
+
of the record turned the Proxy into a plain object with no `getTime`. A Proxy whose prototype chain holds
|
|
103
|
+
`Date.prototype` is now copied as the date it answers as, and an object that only has methods named like a date's is
|
|
104
|
+
not taken for one. An answer with more elements or keys than a copy follows, or an array where a record is promised, is
|
|
105
|
+
refused as `auth.internal`.
|
|
106
|
+
|
|
107
|
+
### Changed
|
|
108
|
+
|
|
109
|
+
- **A date that is not a time is refused.** A record a repository returns with a date in a field that decides an
|
|
110
|
+
admission that compares false with every instant (an Invalid Date, or a Proxy whose `getTime` answers something that
|
|
111
|
+
is not a time, a string and an empty value among it) ends as `auth.internal`. Before, and in 1.5.11 and earlier, it was copied as it was, and a workspace
|
|
112
|
+
pending deletion whose deadline was such a date was finalized, because `due.getTime() > now` is false for it, and
|
|
113
|
+
could be restored past its grace period.
|
|
114
|
+
- **The fields of the contract are visible to a spread of the copy.** An entity that serves its fields through its
|
|
115
|
+
prototype (a Sequelize or Mongoose one) used to log in and then fail every later request with a 401, because the copy
|
|
116
|
+
kept those fields out of the token payload. They are now enumerable, except the credentials (`passwordHash`,
|
|
117
|
+
`mfaSecret`, `mfaRecoveryCodes`, `digest`), which are as visible as the host's record made them, so no spread of the
|
|
118
|
+
copy can carry them out.
|
|
119
|
+
- **Apply to a derived backend:** a repository has to serve every field a service decides on, as the type the
|
|
120
|
+
interface declares. A record that does not now ends as `auth.internal` (HTTP 500, no token) where 1.5.11 and earlier
|
|
121
|
+
accepted it: a field a service decides on that is absent (`mfaEnabled`, `emailVerified`, `status`, `role` or
|
|
122
|
+
`tenantId` missing from the row, which used to read as the default of its type, so an absent `mfaEnabled` was a user
|
|
123
|
+
without a second factor); a number where a string is declared (a numeric `tenantId`); a wrapper where a boolean is
|
|
124
|
+
declared (`new Boolean(false)` is truthy); a date of another class, or an Invalid Date, where a deadline is declared;
|
|
125
|
+
and a function, a symbol or a bigint in any field the contract names. A real `false` for `mfaEnabled` still logs in,
|
|
126
|
+
and a real `true` still gets the second-factor challenge. A column that holds nothing may be `null` or absent where
|
|
127
|
+
the interface marks the field optional.
|
|
128
|
+
|
|
21
129
|
## [1.5.11] - 2026-11-20
|
|
22
130
|
|
|
23
131
|
A patch release.
|
|
@@ -5452,7 +5560,9 @@ ever installable.
|
|
|
5452
5560
|
- 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
|
|
5453
5561
|
- 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
|
|
5454
5562
|
|
|
5455
|
-
[Unreleased]: https://github.com/bymaxone/nest-auth/compare/v1.5.
|
|
5563
|
+
[Unreleased]: https://github.com/bymaxone/nest-auth/compare/v1.5.13...HEAD
|
|
5564
|
+
[1.5.13]: https://github.com/bymaxone/nest-auth/compare/v1.5.12...v1.5.13
|
|
5565
|
+
[1.5.12]: https://github.com/bymaxone/nest-auth/compare/v1.5.11...v1.5.12
|
|
5456
5566
|
[1.5.11]: https://github.com/bymaxone/nest-auth/compare/v1.5.10...v1.5.11
|
|
5457
5567
|
[1.5.10]: https://github.com/bymaxone/nest-auth/compare/v1.5.9...v1.5.10
|
|
5458
5568
|
[1.5.9]: https://github.com/bymaxone/nest-auth/compare/v1.5.8...v1.5.9
|
package/README.md
CHANGED
|
@@ -1408,9 +1408,9 @@ With `@opentelemetry/api` installed and an SDK registered, each of these routes
|
|
|
1408
1408
|
|
|
1409
1409
|
| Span | Routes |
|
|
1410
1410
|
| --------------------- | ----------------------------------------------------------------- |
|
|
1411
|
-
| `auth.login` | `POST /login`, `POST /platform/
|
|
1412
|
-
| `auth.refresh` | `POST /refresh`, `POST /platform/
|
|
1413
|
-
| `auth.mfa.verify` | `POST /mfa/challenge`, `POST /platform/
|
|
1411
|
+
| `auth.login` | `POST /login`, `POST /platform/login` |
|
|
1412
|
+
| `auth.refresh` | `POST /refresh`, `POST /platform/refresh` |
|
|
1413
|
+
| `auth.mfa.verify` | `POST /mfa/challenge`, `POST /platform/mfa/challenge` |
|
|
1414
1414
|
| `auth.password_reset` | `POST /password/forgot-password`, `POST /password/reset-password` |
|
|
1415
1415
|
|
|
1416
1416
|
### Readiness
|
|
@@ -1494,7 +1494,7 @@ A Nest `Logger` calls the host logger and discards what it returns, so a host lo
|
|
|
1494
1494
|
The fields that name a step come from sets the library owns, typed in the code and listed here; none is ever text a host or a store wrote.
|
|
1495
1495
|
|
|
1496
1496
|
- **`hook`** of `AUTH_HOOK_FAILED`: `beforeRegister`, `afterRegister`, `beforeLogin`, `afterLogin`, `afterLogout`, `afterPlatformLogout`, `onLoginFailed`, `onLockout`, `onRefreshTokenReuseDetected`, `afterMfaEnabled`, `afterMfaDisabled`, `afterMfaRecoveryCodesRegenerated`, `onNewSession`, `afterEmailVerified`, `afterPasswordReset`, `onOAuthLogin`, `afterInvitationAccepted`, `onSessionEvicted`, `onApiKeyRequest`, `beforeWorkspaceCreate`, `onWorkspaceEvent`, `updateLastLogin`, `accessDenied`, `maxSessionsResolver`.
|
|
1497
|
-
- **`operation`** of `AUTH_STORE_FAILED` and `AUTH_STORE_DEGRADED`: `account_status_cache_write`, `api_key_last_used_flush`, `api_key_lookup`, `cache_invalidation`, `dead_member_prune`, `grace_pointer_prune`, `invitation_withdraw`, `logout_marker_clear`, `logout_owner_keep`, `mfa_lock_release`, `mfa_reencryption`, `new_session_user_lookup`, `rehash_on_verify`, `reset_account_lookup`, `reset_cooldown_release`, `reset_cooldown_store`, `reset_issue`, `session_cleanup`, `session_detail_read`, `session_detail_rotation`, `workspace_cache_read`, `workspace_cache_write`.
|
|
1497
|
+
- **`operation`** of `AUTH_STORE_FAILED` and `AUTH_STORE_DEGRADED`: `account_status_cache_write`, `api_key_last_used_flush`, `api_key_lookup`, `cache_invalidation`, `dead_member_prune`, `grace_pointer_prune`, `invitation_withdraw`, `logout_marker_clear`, `logout_owner_keep`, `mfa_lock_release`, `mfa_reencryption`, `new_session_user_lookup`, `rehash_on_verify`, `resend_cooldown_release`, `reset_account_lookup`, `reset_cooldown_release`, `reset_cooldown_store`, `reset_issue`, `session_cleanup`, `session_detail_read`, `session_detail_rotation`, `workspace_cache_read`, `workspace_cache_write`.
|
|
1498
1498
|
- **`kind`** of `AUTH_DELIVERY_FAILED`: `passwordResetToken`, `passwordResetOtp`, `emailVerificationOtp`, `passwordChanged`, `emailChangeVerification`, `emailChanged`, `mfaEnabled`, `mfaDisabled`, `newSessionAlert`, `invitation`, `workspaceInvitation`, `email_verification_otp`, `password_changed_notice`, `password_reset_token`, `password_reset_otp`, `mfa_enabled_notice`, `mfa_disabled_notice`, `mfa_reset_notice`, `email_change_notice`.
|
|
1499
1499
|
|
|
1500
1500
|
---
|