@bymax-one/nest-auth 1.5.0 → 1.5.1
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 +79 -1
- package/README.md +33 -4
- package/dist/client/index.cjs +9 -9
- package/dist/client/index.mjs +10 -10
- package/dist/react/index.cjs +18 -8
- package/dist/react/index.mjs +18 -8
- package/dist/server/index.cjs +117 -0
- package/dist/server/index.d.cts +105 -2
- package/dist/server/index.d.ts +105 -2
- package/dist/server/index.mjs +117 -1
- package/dist/shared/index.cjs +1 -0
- package/dist/shared/index.d.cts +55 -1
- package/dist/shared/index.d.ts +55 -1
- package/dist/shared/index.mjs +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -18,6 +18,83 @@ what moves, and that note is the compatibility contract until strict SemVer begi
|
|
|
18
18
|
|
|
19
19
|
## [Unreleased]
|
|
20
20
|
|
|
21
|
+
## [1.5.1] - 2026-11-11
|
|
22
|
+
|
|
23
|
+
A patch release for workspaces: it adds the way to remove an account's memberships before the host deletes
|
|
24
|
+
the account, fixes a wrong-account list in a tab that hears a broadcast, makes the shared contract valid for
|
|
25
|
+
a strict parser, and measures the frontend bundle. **One required port method is added: read the first
|
|
26
|
+
note below.**
|
|
27
|
+
|
|
28
|
+
### Apply to a derived backend
|
|
29
|
+
|
|
30
|
+
- **`IMembershipRepository` gains a REQUIRED method, `removeAllForUser`: every implementer must add
|
|
31
|
+
it.** It removes every membership of an account, in every membership status (active or suspended)
|
|
32
|
+
and in every workspace status, in one transaction, persisting one `member.removed` audit row per
|
|
33
|
+
removal, and answers the removed `{ workspaceId, role }` list. In the same transaction it applies the
|
|
34
|
+
last-owner rule: when the account is the only active owner of a workspace that is not
|
|
35
|
+
`pending_deletion` or `deleted`, it removes nothing, writes no audit row and answers `{ result:
|
|
36
|
+
'last_owner', workspaceIds }`. It is required, not optional, because `listForUser` lists only the
|
|
37
|
+
active memberships of active workspaces, so a fallback built on it would silently leave the suspended
|
|
38
|
+
memberships and the memberships in other workspaces behind. A host that does not enable workspaces
|
|
39
|
+
implements nothing.
|
|
40
|
+
- **Call `MembershipService.removeAllForUser(tenantId, userId, actorUserId, context)` before you
|
|
41
|
+
delete or anonymise a user.** The library never deletes a user, and until now the membership rows of
|
|
42
|
+
a deleted user stayed behind: they still showed in `listForWorkspace`, a deleted owner still counted,
|
|
43
|
+
and a workspace whose only owner was deleted was never seen as orphaned. The call refuses with `409 auth.last_owner` and
|
|
44
|
+
`details.workspaces` (`{ id, name, status }`, at most 100; `{ id }` alone for one the repository found
|
|
45
|
+
during the write) while the account is the only owner of an active or suspended workspace, so you can
|
|
46
|
+
transfer ownership or schedule the workspace's deletion first. A workspace pending deletion does not block, because no one can finalize
|
|
47
|
+
it before its grace period ends: the owner's membership there is removed, the workspace can no longer
|
|
48
|
+
be restored, and your finalize job deletes it when the grace period ends. If a cache bump fails after
|
|
49
|
+
the commit it throws `MembershipBumpFailedError` with `removed` and `failed`; repeating the call
|
|
50
|
+
removes nothing, so drop the access of each `failed` entry with
|
|
51
|
+
`WorkspaceAccessService.invalidateMembership`.
|
|
52
|
+
- **The shared wire contract is at version 4, and its bytes changed.** The new section
|
|
53
|
+
`workspaceAccountRemoval` holds the rules and the blocking vectors, and the `workspaceScopedName`
|
|
54
|
+
refusal vector for an unpaired surrogate now carries `unpairedSurrogateCodeUnits: [55296]` (one more
|
|
55
|
+
final part, built from those UTF-16 code units) instead of a lone surrogate escape, which a parser
|
|
56
|
+
that builds well-formed strings, `serde_json` among them, rejects, so the sibling library lost the
|
|
57
|
+
whole file. Every string in `conformance/` is now held to well-formed Unicode by a test. The
|
|
58
|
+
contract's sha256 is `1e4c38e1741c21e639e4099cd33ece9b04518cf69699fb39fd9d5b9d37352edd`; a copy kept
|
|
59
|
+
by another library is refreshed from `conformance/wire-contract.json`, and a library that reads the
|
|
60
|
+
vector builds the lone surrogate itself.
|
|
61
|
+
- **`AUTH_WORKSPACE_ROUTES` is exported from `./shared`,** as the README and the specification already
|
|
62
|
+
said it was; before, it was reachable only as `AUTH_ROUTES.workspaces`.
|
|
63
|
+
- **A frontend that uses no workspace ships less.** `createAuthClient` imports its own route groups
|
|
64
|
+
instead of the aggregate `AUTH_ROUTES`, which kept every route family, the 16 workspace routes among
|
|
65
|
+
them, in the bundle. Measured with the same minified, tree-shaken minimal import: `createAuthClient`
|
|
66
|
+
is **3.12 KiB** brotli, against 3.45 KiB in 1.5.0 and **3.57 KiB in 1.4.22**. The 1.5.0 note that
|
|
67
|
+
said "from 3.82 to 3.45" was wrong about the starting point: 1.4.22 measures 3.57, so the 1.4.22 to
|
|
68
|
+
1.5.0 change is 3.57 to 3.45, and `AuthProvider` plus `useSession` 1.26 to 1.13 KiB stands.
|
|
69
|
+
|
|
70
|
+
### Added
|
|
71
|
+
|
|
72
|
+
- **`MembershipService.removeAllForUser` and `MembershipBumpFailedError`,** described above, with the
|
|
73
|
+
port method `IMembershipRepository.removeAllForUser` and its types (`RemoveAllMembershipsParams`,
|
|
74
|
+
`RemoveAllMembershipsResult`, `RemovedMembership`, `AccountRemovalAudit`).
|
|
75
|
+
- **A "Deleting an account" section in the README** and §22.3a in the technical specification.
|
|
76
|
+
|
|
77
|
+
### Fixed
|
|
78
|
+
|
|
79
|
+
- **A tab whose session still named the previous account no longer shows the new account's workspaces
|
|
80
|
+
after a broadcast.** After another tab changed the signed-in account, the tab reloaded the list with
|
|
81
|
+
the browser's cookie, which already belonged to the new account, and showed it under the old
|
|
82
|
+
identity until the session revalidated. A broadcast now revalidates the session first and reloads the
|
|
83
|
+
list only when the account is unchanged; when it changed, the account change loads the new account's
|
|
84
|
+
list. A signed-out tab still makes no request. A revalidation that fails with an error other than an
|
|
85
|
+
expired session ends the tab's session view, as every revalidation of the auth provider already does.
|
|
86
|
+
- **The shared contract can be read by a strict parser:** see the contract note above.
|
|
87
|
+
- **The README states where a workspace invitation token travels:** in a POST body on the API routes;
|
|
88
|
+
the one use of a query string is the OAuth sign-in start, `GET /oauth/:provider?workspaceInvitation=`,
|
|
89
|
+
which stores only the token's sha256 and answers with `Referrer-Policy: no-referrer`.
|
|
90
|
+
|
|
91
|
+
### Maintenance
|
|
92
|
+
|
|
93
|
+
Repository tooling; nothing changes for a host. The weekly cold mutation job runs as four shards of two
|
|
94
|
+
workers each on the shared sharded workflow, after a run at four workers lost its runner twice; the
|
|
95
|
+
size budgets of the two auth surfaces are tightened to the measured size plus about 5% (client 3.3 KiB,
|
|
96
|
+
react 1.2 KiB) and the react workspace surface and entry are 2.5 and 3.6 KiB.
|
|
97
|
+
|
|
21
98
|
## [1.5.0] - 2026-11-11
|
|
22
99
|
|
|
23
100
|
**Workspaces.** One identity can now hold a role in each of many workspaces inside a tenant,
|
|
@@ -4831,7 +4908,8 @@ ever installable.
|
|
|
4831
4908
|
- 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
|
|
4832
4909
|
- 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
|
|
4833
4910
|
|
|
4834
|
-
[Unreleased]: https://github.com/bymaxone/nest-auth/compare/v1.5.
|
|
4911
|
+
[Unreleased]: https://github.com/bymaxone/nest-auth/compare/v1.5.1...HEAD
|
|
4912
|
+
[1.5.1]: https://github.com/bymaxone/nest-auth/compare/v1.5.0...v1.5.1
|
|
4835
4913
|
[1.5.0]: https://github.com/bymaxone/nest-auth/compare/v1.4.22...v1.5.0
|
|
4836
4914
|
[1.4.22]: https://github.com/bymaxone/nest-auth/compare/v1.4.21...v1.4.22
|
|
4837
4915
|
[1.4.21]: https://github.com/bymaxone/nest-auth/compare/v1.4.20...v1.4.21
|
package/README.md
CHANGED
|
@@ -1482,7 +1482,7 @@ BymaxAuthModule.registerAsync({
|
|
|
1482
1482
|
|
|
1483
1483
|
You implement two ports: `IWorkspaceRepository` (`createWithOwner`, `findById`, `rename`,
|
|
1484
1484
|
`updateStatus`) and `IMembershipRepository` (`find`, `listForUser`, `listForWorkspace`, `create`,
|
|
1485
|
-
`changeRole`, `remove`, `transferOwnership`, `countOwned`, `listSoleOwned`). Every call carries the
|
|
1485
|
+
`changeRole`, `remove`, `removeAllForUser`, `transferOwnership`, `countOwned`, `listSoleOwned`). Every call carries the
|
|
1486
1486
|
tenant and the workspace. The writes that must not race (a role change, a removal, an ownership
|
|
1487
1487
|
transfer) are guarded writes the repository answers atomically, so two requests cannot both remove
|
|
1488
1488
|
the last owner.
|
|
@@ -1565,9 +1565,11 @@ header.
|
|
|
1565
1565
|
With `controllers.workspaceInvitations: true`: `POST` and `GET workspaces/:workspaceId/invitations`
|
|
1566
1566
|
(invite, list pending), `POST .../invitations/resend` and `.../invitations/revoke`, and the
|
|
1567
1567
|
token-based `POST workspaces/invitations/preview` (public), `.../accept` (the signed-in account the
|
|
1568
|
-
invitation was addressed to) and `.../accept-signup` (public, creates the account).
|
|
1569
|
-
in a POST body, never in a query string
|
|
1570
|
-
|
|
1568
|
+
invitation was addressed to) and `.../accept-signup` (public, creates the account). On these routes
|
|
1569
|
+
the token travels in a POST body, never in a query string. The one exception is the OAuth sign-in
|
|
1570
|
+
start, `GET /oauth/:provider?workspaceInvitation=<token>`: it stores only the token's sha256 in the
|
|
1571
|
+
state record and answers with `Referrer-Policy: no-referrer`. On your accept page, put the token in
|
|
1572
|
+
the URL fragment and set `Referrer-Policy: no-referrer` there.
|
|
1571
1573
|
|
|
1572
1574
|
### Hooks and events
|
|
1573
1575
|
|
|
@@ -1578,6 +1580,33 @@ context)` receives, after the change has committed, `workspace.created`, `.renam
|
|
|
1578
1580
|
`workspace.switched`; and `access.denied` (with the `surface`, the public `code` and a host-only
|
|
1579
1581
|
`reason`). It is best-effort and informational: the repository's persisted audit row is the record.
|
|
1580
1582
|
|
|
1583
|
+
### Deleting an account
|
|
1584
|
+
|
|
1585
|
+
The library never deletes a user: `IUserRepository` has no delete. A host that deletes or anonymises
|
|
1586
|
+
a user row must remove that user's memberships first, or the rows stay behind, still count as
|
|
1587
|
+
members of their workspaces, and a deleted owner keeps a workspace from ever being seen as
|
|
1588
|
+
orphaned. Call `MembershipService.removeAllForUser(tenantId, userId, actorUserId, context)` before
|
|
1589
|
+
the delete. `actorUserId` is the account itself, an administrator, or `null` for a job.
|
|
1590
|
+
|
|
1591
|
+
It removes every membership of the account, in every membership status and every workspace, with one
|
|
1592
|
+
`member.removed` event per removal and the cached access of each dropped, so access ends at the next
|
|
1593
|
+
request. Only the repository can find them all (`listForUser` lists active memberships of active
|
|
1594
|
+
workspaces only), so it is one call on the membership port, `removeAllForUser`, which you implement
|
|
1595
|
+
in one transaction together with the audit rows.
|
|
1596
|
+
|
|
1597
|
+
- **It refuses while the account is the only owner of an active or suspended workspace:** `409
|
|
1598
|
+
auth.last_owner` with `details.workspaces` (`{ id, name, status }`, at most 100; `{ id }` alone for one the repository found during the write), and nothing is
|
|
1599
|
+
removed. Transfer ownership or schedule the workspace's deletion first.
|
|
1600
|
+
- **A workspace pending deletion does not block.** No one can finalize a pending deletion before
|
|
1601
|
+
its grace period ends, so an owner who scheduled one would otherwise be unable to delete their own
|
|
1602
|
+
account for the whole period. Their membership there is removed with the rest, the workspace can no
|
|
1603
|
+
longer be restored (restoring is owner-only), and your finalize job deletes it when the grace period
|
|
1604
|
+
ends.
|
|
1605
|
+
- **If a cache bump fails after the commit,** the call throws `MembershipBumpFailedError` with
|
|
1606
|
+
`removed` and `failed`. The removal is already committed, so calling it again removes nothing: drop
|
|
1607
|
+
the access of each entry of `failed` with `WorkspaceAccessService.invalidateMembership`, or wait out
|
|
1608
|
+
`membershipCacheTtlSeconds`.
|
|
1609
|
+
|
|
1581
1610
|
### Accepting an invitation through OAuth, and MFA
|
|
1582
1611
|
|
|
1583
1612
|
An OAuth flow started with a workspace invitation vets the invitation against the provider's profile
|
package/dist/client/index.cjs
CHANGED
|
@@ -341,22 +341,22 @@ function createAuthClient(config) {
|
|
|
341
341
|
}
|
|
342
342
|
return {
|
|
343
343
|
async login(input) {
|
|
344
|
-
return post(shared.
|
|
344
|
+
return post(shared.AUTH_DASHBOARD_ROUTES.login, input);
|
|
345
345
|
},
|
|
346
346
|
async register(data) {
|
|
347
|
-
return post(shared.
|
|
347
|
+
return post(shared.AUTH_DASHBOARD_ROUTES.register, data);
|
|
348
348
|
},
|
|
349
349
|
async logout() {
|
|
350
|
-
return postNoContent(shared.
|
|
350
|
+
return postNoContent(shared.AUTH_DASHBOARD_ROUTES.logout, {});
|
|
351
351
|
},
|
|
352
352
|
async refresh() {
|
|
353
|
-
return post(shared.
|
|
353
|
+
return post(shared.AUTH_DASHBOARD_ROUTES.refresh, {});
|
|
354
354
|
},
|
|
355
355
|
async getMe() {
|
|
356
|
-
return get(shared.
|
|
356
|
+
return get(shared.AUTH_DASHBOARD_ROUTES.me);
|
|
357
357
|
},
|
|
358
358
|
async mfaChallenge(tempToken, code) {
|
|
359
|
-
const result = await post(shared.
|
|
359
|
+
const result = await post(shared.AUTH_MFA_ROUTES.challenge, {
|
|
360
360
|
mfaTempToken: tempToken,
|
|
361
361
|
code
|
|
362
362
|
});
|
|
@@ -369,7 +369,7 @@ function createAuthClient(config) {
|
|
|
369
369
|
return result;
|
|
370
370
|
},
|
|
371
371
|
async forgotPassword(email, tenantId) {
|
|
372
|
-
return postNoContent(shared.
|
|
372
|
+
return postNoContent(shared.AUTH_PASSWORD_ROUTES.forgotPassword, {
|
|
373
373
|
email,
|
|
374
374
|
...tenantId !== void 0 ? { tenantId } : {}
|
|
375
375
|
});
|
|
@@ -383,11 +383,11 @@ function createAuthClient(config) {
|
|
|
383
383
|
if (input.token !== void 0) payload["token"] = input.token;
|
|
384
384
|
if (input.otp !== void 0) payload["otp"] = input.otp;
|
|
385
385
|
if (input.verifiedToken !== void 0) payload["verifiedToken"] = input.verifiedToken;
|
|
386
|
-
return postNoContent(shared.
|
|
386
|
+
return postNoContent(shared.AUTH_PASSWORD_ROUTES.resetPassword, payload);
|
|
387
387
|
}
|
|
388
388
|
};
|
|
389
389
|
}
|
|
390
|
-
var ROUTES = shared.
|
|
390
|
+
var ROUTES = shared.AUTH_WORKSPACE_ROUTES;
|
|
391
391
|
function paged(path, page) {
|
|
392
392
|
const query = new URLSearchParams();
|
|
393
393
|
if (page?.cursor !== void 0) query.set("cursor", page.cursor);
|
package/dist/client/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AUTH_ERROR_CODES,
|
|
1
|
+
import { AUTH_ERROR_CODES, AUTH_PROXY_ROUTES, buildAuthRefreshSkipSuffixes, AUTH_PASSWORD_ROUTES, AUTH_MFA_ROUTES, AuthClientError, AUTH_DASHBOARD_ROUTES, AUTH_WORKSPACE_ROUTES, trimSlashes, fillRoute } from '@bymax-one/nest-auth/shared';
|
|
2
2
|
export { AuthClientError } from '@bymax-one/nest-auth/shared';
|
|
3
3
|
|
|
4
4
|
// src/client/createAuthFetch.ts
|
|
@@ -340,22 +340,22 @@ function createAuthClient(config) {
|
|
|
340
340
|
}
|
|
341
341
|
return {
|
|
342
342
|
async login(input) {
|
|
343
|
-
return post(
|
|
343
|
+
return post(AUTH_DASHBOARD_ROUTES.login, input);
|
|
344
344
|
},
|
|
345
345
|
async register(data) {
|
|
346
|
-
return post(
|
|
346
|
+
return post(AUTH_DASHBOARD_ROUTES.register, data);
|
|
347
347
|
},
|
|
348
348
|
async logout() {
|
|
349
|
-
return postNoContent(
|
|
349
|
+
return postNoContent(AUTH_DASHBOARD_ROUTES.logout, {});
|
|
350
350
|
},
|
|
351
351
|
async refresh() {
|
|
352
|
-
return post(
|
|
352
|
+
return post(AUTH_DASHBOARD_ROUTES.refresh, {});
|
|
353
353
|
},
|
|
354
354
|
async getMe() {
|
|
355
|
-
return get(
|
|
355
|
+
return get(AUTH_DASHBOARD_ROUTES.me);
|
|
356
356
|
},
|
|
357
357
|
async mfaChallenge(tempToken, code) {
|
|
358
|
-
const result = await post(
|
|
358
|
+
const result = await post(AUTH_MFA_ROUTES.challenge, {
|
|
359
359
|
mfaTempToken: tempToken,
|
|
360
360
|
code
|
|
361
361
|
});
|
|
@@ -368,7 +368,7 @@ function createAuthClient(config) {
|
|
|
368
368
|
return result;
|
|
369
369
|
},
|
|
370
370
|
async forgotPassword(email, tenantId) {
|
|
371
|
-
return postNoContent(
|
|
371
|
+
return postNoContent(AUTH_PASSWORD_ROUTES.forgotPassword, {
|
|
372
372
|
email,
|
|
373
373
|
...tenantId !== void 0 ? { tenantId } : {}
|
|
374
374
|
});
|
|
@@ -382,11 +382,11 @@ function createAuthClient(config) {
|
|
|
382
382
|
if (input.token !== void 0) payload["token"] = input.token;
|
|
383
383
|
if (input.otp !== void 0) payload["otp"] = input.otp;
|
|
384
384
|
if (input.verifiedToken !== void 0) payload["verifiedToken"] = input.verifiedToken;
|
|
385
|
-
return postNoContent(
|
|
385
|
+
return postNoContent(AUTH_PASSWORD_ROUTES.resetPassword, payload);
|
|
386
386
|
}
|
|
387
387
|
};
|
|
388
388
|
}
|
|
389
|
-
var ROUTES =
|
|
389
|
+
var ROUTES = AUTH_WORKSPACE_ROUTES;
|
|
390
390
|
function paged(path, page) {
|
|
391
391
|
const query = new URLSearchParams();
|
|
392
392
|
if (page?.cursor !== void 0) query.set("cursor", page.cursor);
|
package/dist/react/index.cjs
CHANGED
|
@@ -354,7 +354,7 @@ function useWorkspaceList(client, authStatus, identity) {
|
|
|
354
354
|
};
|
|
355
355
|
}, [authStatus, identity, refresh]);
|
|
356
356
|
const loaded = stored.owner === identity ? stored : identity === null ? IDLE : loadingFor(identity);
|
|
357
|
-
return { loaded, setLoaded, clientRef, identityRef, refresh };
|
|
357
|
+
return { loaded, setLoaded, clientRef, identityRef, statusRef, refresh };
|
|
358
358
|
}
|
|
359
359
|
function useChangeNotice(status, active, optionsRef) {
|
|
360
360
|
const previousRef = react.useRef(
|
|
@@ -372,20 +372,29 @@ function useChangeNotice(status, active, optionsRef) {
|
|
|
372
372
|
);
|
|
373
373
|
}, [status, active, optionsRef]);
|
|
374
374
|
}
|
|
375
|
-
function
|
|
375
|
+
function useBroadcastReload(sessionRefresh, statusRef, identityRef, reload) {
|
|
376
|
+
const [request, setRequest] = react.useState(null);
|
|
377
|
+
react.useEffect(() => {
|
|
378
|
+
if (request !== null && request.heardAs === identityRef.current) void reload();
|
|
379
|
+
}, [request, identityRef, reload]);
|
|
380
|
+
return react.useCallback(() => {
|
|
381
|
+
if (statusRef.current !== "authenticated") return;
|
|
382
|
+
const heardAs = identityRef.current;
|
|
383
|
+
void sessionRefresh().then(() => setRequest({ heardAs }));
|
|
384
|
+
}, [sessionRefresh, statusRef, identityRef]);
|
|
385
|
+
}
|
|
386
|
+
function useWorkspaceChannel(onMessage) {
|
|
376
387
|
const channelRef = react.useRef(null);
|
|
377
388
|
react.useEffect(() => {
|
|
378
389
|
if (typeof BroadcastChannel === "undefined") return void 0;
|
|
379
390
|
const channel = new BroadcastChannel(CHANNEL_NAME);
|
|
380
|
-
channel.onmessage =
|
|
381
|
-
void refresh();
|
|
382
|
-
};
|
|
391
|
+
channel.onmessage = onMessage;
|
|
383
392
|
channelRef.current = channel;
|
|
384
393
|
return () => {
|
|
385
394
|
channelRef.current = null;
|
|
386
395
|
channel.close();
|
|
387
396
|
};
|
|
388
|
-
}, [
|
|
397
|
+
}, [onMessage]);
|
|
389
398
|
return channelRef;
|
|
390
399
|
}
|
|
391
400
|
function useRoleHint(active, items, optionsRef) {
|
|
@@ -449,7 +458,7 @@ function WorkspaceProvider({
|
|
|
449
458
|
optionsRef.current = options;
|
|
450
459
|
});
|
|
451
460
|
const identity = ctx.user === null ? null : JSON.stringify([ctx.user.tenantId, ctx.user.id]);
|
|
452
|
-
const { loaded, setLoaded, clientRef, identityRef, refresh } = useWorkspaceList(
|
|
461
|
+
const { loaded, setLoaded, clientRef, identityRef, statusRef, refresh } = useWorkspaceList(
|
|
453
462
|
client,
|
|
454
463
|
ctx.status,
|
|
455
464
|
identity
|
|
@@ -460,7 +469,8 @@ function WorkspaceProvider({
|
|
|
460
469
|
[loaded.items, activeId]
|
|
461
470
|
);
|
|
462
471
|
useChangeNotice(loaded.status, activeWorkspace, optionsRef);
|
|
463
|
-
const
|
|
472
|
+
const onBroadcast = useBroadcastReload(ctx.refresh, statusRef, identityRef, refresh);
|
|
473
|
+
const channelRef = useWorkspaceChannel(onBroadcast);
|
|
464
474
|
const hasWorkspaceRole = useRoleHint(activeWorkspace, loaded.items, optionsRef);
|
|
465
475
|
const handleWorkspaceError = useRefusalHandler(activeId, optionsRef, refresh);
|
|
466
476
|
const switchWorkspace = useSwitch(clientRef, identityRef, setLoaded, channelRef);
|
package/dist/react/index.mjs
CHANGED
|
@@ -352,7 +352,7 @@ function useWorkspaceList(client, authStatus, identity) {
|
|
|
352
352
|
};
|
|
353
353
|
}, [authStatus, identity, refresh]);
|
|
354
354
|
const loaded = stored.owner === identity ? stored : identity === null ? IDLE : loadingFor(identity);
|
|
355
|
-
return { loaded, setLoaded, clientRef, identityRef, refresh };
|
|
355
|
+
return { loaded, setLoaded, clientRef, identityRef, statusRef, refresh };
|
|
356
356
|
}
|
|
357
357
|
function useChangeNotice(status, active, optionsRef) {
|
|
358
358
|
const previousRef = useRef(
|
|
@@ -370,20 +370,29 @@ function useChangeNotice(status, active, optionsRef) {
|
|
|
370
370
|
);
|
|
371
371
|
}, [status, active, optionsRef]);
|
|
372
372
|
}
|
|
373
|
-
function
|
|
373
|
+
function useBroadcastReload(sessionRefresh, statusRef, identityRef, reload) {
|
|
374
|
+
const [request, setRequest] = useState(null);
|
|
375
|
+
useEffect(() => {
|
|
376
|
+
if (request !== null && request.heardAs === identityRef.current) void reload();
|
|
377
|
+
}, [request, identityRef, reload]);
|
|
378
|
+
return useCallback(() => {
|
|
379
|
+
if (statusRef.current !== "authenticated") return;
|
|
380
|
+
const heardAs = identityRef.current;
|
|
381
|
+
void sessionRefresh().then(() => setRequest({ heardAs }));
|
|
382
|
+
}, [sessionRefresh, statusRef, identityRef]);
|
|
383
|
+
}
|
|
384
|
+
function useWorkspaceChannel(onMessage) {
|
|
374
385
|
const channelRef = useRef(null);
|
|
375
386
|
useEffect(() => {
|
|
376
387
|
if (typeof BroadcastChannel === "undefined") return void 0;
|
|
377
388
|
const channel = new BroadcastChannel(CHANNEL_NAME);
|
|
378
|
-
channel.onmessage =
|
|
379
|
-
void refresh();
|
|
380
|
-
};
|
|
389
|
+
channel.onmessage = onMessage;
|
|
381
390
|
channelRef.current = channel;
|
|
382
391
|
return () => {
|
|
383
392
|
channelRef.current = null;
|
|
384
393
|
channel.close();
|
|
385
394
|
};
|
|
386
|
-
}, [
|
|
395
|
+
}, [onMessage]);
|
|
387
396
|
return channelRef;
|
|
388
397
|
}
|
|
389
398
|
function useRoleHint(active, items, optionsRef) {
|
|
@@ -447,7 +456,7 @@ function WorkspaceProvider({
|
|
|
447
456
|
optionsRef.current = options;
|
|
448
457
|
});
|
|
449
458
|
const identity = ctx.user === null ? null : JSON.stringify([ctx.user.tenantId, ctx.user.id]);
|
|
450
|
-
const { loaded, setLoaded, clientRef, identityRef, refresh } = useWorkspaceList(
|
|
459
|
+
const { loaded, setLoaded, clientRef, identityRef, statusRef, refresh } = useWorkspaceList(
|
|
451
460
|
client,
|
|
452
461
|
ctx.status,
|
|
453
462
|
identity
|
|
@@ -458,7 +467,8 @@ function WorkspaceProvider({
|
|
|
458
467
|
[loaded.items, activeId]
|
|
459
468
|
);
|
|
460
469
|
useChangeNotice(loaded.status, activeWorkspace, optionsRef);
|
|
461
|
-
const
|
|
470
|
+
const onBroadcast = useBroadcastReload(ctx.refresh, statusRef, identityRef, refresh);
|
|
471
|
+
const channelRef = useWorkspaceChannel(onBroadcast);
|
|
462
472
|
const hasWorkspaceRole = useRoleHint(activeWorkspace, loaded.items, optionsRef);
|
|
463
473
|
const handleWorkspaceError = useRefusalHandler(activeId, optionsRef, refresh);
|
|
464
474
|
const switchWorkspace = useSwitch(clientRef, identityRef, setLoaded, channelRef);
|
package/dist/server/index.cjs
CHANGED
|
@@ -15960,6 +15960,23 @@ function pageSize(limit) {
|
|
|
15960
15960
|
return Math.min(Math.max(limit, 1), MAX_PAGE_SIZE);
|
|
15961
15961
|
}
|
|
15962
15962
|
__name(pageSize, "pageSize");
|
|
15963
|
+
var MembershipBumpFailedError = class extends Error {
|
|
15964
|
+
static {
|
|
15965
|
+
__name(this, "MembershipBumpFailedError");
|
|
15966
|
+
}
|
|
15967
|
+
removed;
|
|
15968
|
+
failed;
|
|
15969
|
+
cause;
|
|
15970
|
+
/**
|
|
15971
|
+
* @param removed - Every membership the removal deleted.
|
|
15972
|
+
* @param failed - The ones whose cached access could not be dropped.
|
|
15973
|
+
* @param cause - The first error a bump failed with.
|
|
15974
|
+
*/
|
|
15975
|
+
constructor(removed, failed, cause) {
|
|
15976
|
+
super("The memberships were removed but their cached access could not be dropped."), this.removed = removed, this.failed = failed, this.cause = cause;
|
|
15977
|
+
this.name = "MembershipBumpFailedError";
|
|
15978
|
+
}
|
|
15979
|
+
};
|
|
15963
15980
|
exports.MembershipService = class MembershipService {
|
|
15964
15981
|
static {
|
|
15965
15982
|
__name(this, "MembershipService");
|
|
@@ -16041,6 +16058,76 @@ exports.MembershipService = class MembershipService {
|
|
|
16041
16058
|
});
|
|
16042
16059
|
}
|
|
16043
16060
|
/**
|
|
16061
|
+
* Removes every membership of an account that is about to be deleted or anonymised: in every
|
|
16062
|
+
* membership status and every workspace, with one `member.removed` event per removal and the
|
|
16063
|
+
* cached access of each dropped.
|
|
16064
|
+
*
|
|
16065
|
+
* Refuses while the account is the only owner of an active or suspended workspace, so the host can
|
|
16066
|
+
* transfer ownership or schedule deletion first. A workspace pending deletion does not block:
|
|
16067
|
+
* no one can finalize it early, so the owner's membership there is removed too, the workspace can
|
|
16068
|
+
* no longer be restored, and the host's finalize job deletes it when its grace period ends.
|
|
16069
|
+
*
|
|
16070
|
+
* @param tenantId - The account's tenant.
|
|
16071
|
+
* @param userId - The account.
|
|
16072
|
+
* @param actorUserId - Who authorizes the deletion: the account, an administrator, or `null` for a
|
|
16073
|
+
* job. No workspace role does, so none is checked.
|
|
16074
|
+
* @param context - Request metadata for the hook.
|
|
16075
|
+
* @returns The memberships removed.
|
|
16076
|
+
* @throws {AuthException} `auth.last_owner`, with `details.workspaces`, while a workspace would be
|
|
16077
|
+
* left without an owner; nothing is removed.
|
|
16078
|
+
* @throws {MembershipBumpFailedError} When the removal committed but a cache bump failed.
|
|
16079
|
+
*/
|
|
16080
|
+
async removeAllForUser(tenantId, userId, actorUserId, context) {
|
|
16081
|
+
const blocking = await this.soleOwnedBlocking(tenantId, userId);
|
|
16082
|
+
if (blocking.length > 0) throw new AuthException(AUTH_ERROR_CODES.LAST_OWNER, {
|
|
16083
|
+
workspaces: blocking
|
|
16084
|
+
});
|
|
16085
|
+
const at = now();
|
|
16086
|
+
const outcome = await this.memberships.removeAllForUser({
|
|
16087
|
+
tenantId,
|
|
16088
|
+
userId,
|
|
16089
|
+
ownerRole: this.group.roles.ownerRole,
|
|
16090
|
+
audit: {
|
|
16091
|
+
type: "member.removed",
|
|
16092
|
+
tenantId,
|
|
16093
|
+
actorUserId,
|
|
16094
|
+
userId,
|
|
16095
|
+
at
|
|
16096
|
+
}
|
|
16097
|
+
});
|
|
16098
|
+
if (outcome.result === "last_owner") {
|
|
16099
|
+
throw new AuthException(AUTH_ERROR_CODES.LAST_OWNER, {
|
|
16100
|
+
workspaces: outcome.workspaceIds.map((id) => ({
|
|
16101
|
+
id
|
|
16102
|
+
}))
|
|
16103
|
+
});
|
|
16104
|
+
}
|
|
16105
|
+
const failed = [];
|
|
16106
|
+
let cause;
|
|
16107
|
+
for (const removed of outcome.removed) {
|
|
16108
|
+
this.events.emit({
|
|
16109
|
+
type: "member.removed",
|
|
16110
|
+
tenantId,
|
|
16111
|
+
workspaceId: removed.workspaceId,
|
|
16112
|
+
actorUserId,
|
|
16113
|
+
userId,
|
|
16114
|
+
at
|
|
16115
|
+
}, context);
|
|
16116
|
+
try {
|
|
16117
|
+
await this.access.invalidateMembership({
|
|
16118
|
+
tenantId,
|
|
16119
|
+
workspaceId: removed.workspaceId,
|
|
16120
|
+
userId
|
|
16121
|
+
});
|
|
16122
|
+
} catch (error) {
|
|
16123
|
+
if (failed.length === 0) cause = error;
|
|
16124
|
+
failed.push(removed);
|
|
16125
|
+
}
|
|
16126
|
+
}
|
|
16127
|
+
if (failed.length > 0) throw new MembershipBumpFailedError(outcome.removed, failed, cause);
|
|
16128
|
+
return outcome.removed;
|
|
16129
|
+
}
|
|
16130
|
+
/**
|
|
16044
16131
|
* Changes a member's role.
|
|
16045
16132
|
*
|
|
16046
16133
|
* @param ref - The workspace.
|
|
@@ -16297,6 +16384,35 @@ exports.MembershipService = class MembershipService {
|
|
|
16297
16384
|
const { hierarchy, ownerRole } = this.group.roles;
|
|
16298
16385
|
return actorRole === ownerRole || actorRole !== otherRole && hasRole(actorRole, otherRole, hierarchy);
|
|
16299
16386
|
}
|
|
16387
|
+
/**
|
|
16388
|
+
* The workspaces that stop an account deletion: those the account alone owns, except the ones
|
|
16389
|
+
* pending deletion or deleted. Stops reading pages once a full page of them is known.
|
|
16390
|
+
*/
|
|
16391
|
+
async soleOwnedBlocking(tenantId, userId) {
|
|
16392
|
+
const blocking = [];
|
|
16393
|
+
let cursor;
|
|
16394
|
+
do {
|
|
16395
|
+
const page = await this.memberships.listSoleOwned({
|
|
16396
|
+
tenantId,
|
|
16397
|
+
userId,
|
|
16398
|
+
ownerRole: this.group.roles.ownerRole,
|
|
16399
|
+
...cursor === void 0 ? {} : {
|
|
16400
|
+
cursor
|
|
16401
|
+
},
|
|
16402
|
+
limit: MAX_PAGE_SIZE
|
|
16403
|
+
});
|
|
16404
|
+
for (const workspace of page.items) {
|
|
16405
|
+
if (workspace.status === "pending_deletion" || workspace.status === "deleted") continue;
|
|
16406
|
+
blocking.push({
|
|
16407
|
+
id: workspace.id,
|
|
16408
|
+
name: workspace.name,
|
|
16409
|
+
status: workspace.status
|
|
16410
|
+
});
|
|
16411
|
+
}
|
|
16412
|
+
cursor = page.nextCursor ?? void 0;
|
|
16413
|
+
} while (cursor !== void 0 && blocking.length < MAX_PAGE_SIZE);
|
|
16414
|
+
return blocking.slice(0, MAX_PAGE_SIZE);
|
|
16415
|
+
}
|
|
16300
16416
|
async removeWith(ref, userId, event, context, judged2) {
|
|
16301
16417
|
const result = await this.memberships.remove({
|
|
16302
16418
|
...ref,
|
|
@@ -25029,6 +25145,7 @@ exports.DefaultAuthEmailProvider = DefaultAuthEmailProvider;
|
|
|
25029
25145
|
exports.ForgotPasswordDto = ForgotPasswordDto;
|
|
25030
25146
|
exports.IS_PUBLIC_KEY = IS_PUBLIC_KEY;
|
|
25031
25147
|
exports.LoginDto = LoginDto;
|
|
25148
|
+
exports.MembershipBumpFailedError = MembershipBumpFailedError;
|
|
25032
25149
|
exports.MfaChallengeDto = MfaChallengeDto;
|
|
25033
25150
|
exports.MfaDisableDto = MfaDisableDto;
|
|
25034
25151
|
exports.MfaRegenerateRecoveryCodesDto = MfaRegenerateRecoveryCodesDto;
|
package/dist/server/index.d.cts
CHANGED
|
@@ -4948,6 +4948,48 @@ type GuardedWriteResult = 'ok' | 'not_found' | 'last_owner';
|
|
|
4948
4948
|
type MemberChangeResult = GuardedWriteResult | 'actor_changed';
|
|
4949
4949
|
/** Outcome of {@link IMembershipRepository.transferOwnership}. */
|
|
4950
4950
|
type TransferOwnershipResult = GuardedWriteResult | 'target_not_member';
|
|
4951
|
+
/**
|
|
4952
|
+
* The event persisted for each membership {@link IMembershipRepository.removeAllForUser} deletes.
|
|
4953
|
+
* The repository stores one `member.removed` event per removed membership, naming that
|
|
4954
|
+
* membership's workspace, and nothing else is added to it.
|
|
4955
|
+
*/
|
|
4956
|
+
interface AccountRemovalAudit {
|
|
4957
|
+
type: 'member.removed';
|
|
4958
|
+
/** The tenant of the account. */
|
|
4959
|
+
tenantId: string;
|
|
4960
|
+
/** Who authorized the removal: the member themselves, an administrator, or `null` for a job. */
|
|
4961
|
+
actorUserId: string | null;
|
|
4962
|
+
/** The account whose memberships are removed. */
|
|
4963
|
+
userId: string;
|
|
4964
|
+
/** When the removal was decided, as an ISO-8601 string. */
|
|
4965
|
+
at: string;
|
|
4966
|
+
}
|
|
4967
|
+
/** Input to {@link IMembershipRepository.removeAllForUser}. */
|
|
4968
|
+
interface RemoveAllMembershipsParams {
|
|
4969
|
+
/** The tenant of the account. */
|
|
4970
|
+
tenantId: string;
|
|
4971
|
+
/** The account whose memberships are removed. */
|
|
4972
|
+
userId: string;
|
|
4973
|
+
/** The role that owns a workspace, so the last-owner rule can be decided with the write. */
|
|
4974
|
+
ownerRole: string;
|
|
4975
|
+
/** The event to persist for each membership removed. */
|
|
4976
|
+
audit: AccountRemovalAudit;
|
|
4977
|
+
}
|
|
4978
|
+
/** One membership an account removal deleted. */
|
|
4979
|
+
interface RemovedMembership {
|
|
4980
|
+
/** The workspace the membership was in. */
|
|
4981
|
+
workspaceId: string;
|
|
4982
|
+
/** The role the account held there. */
|
|
4983
|
+
role: string;
|
|
4984
|
+
}
|
|
4985
|
+
/** Outcome of {@link IMembershipRepository.removeAllForUser}. */
|
|
4986
|
+
type RemoveAllMembershipsResult = {
|
|
4987
|
+
result: 'ok';
|
|
4988
|
+
removed: RemovedMembership[];
|
|
4989
|
+
} | {
|
|
4990
|
+
result: 'last_owner';
|
|
4991
|
+
workspaceIds: string[];
|
|
4992
|
+
};
|
|
4951
4993
|
/**
|
|
4952
4994
|
* The membership port a host implements.
|
|
4953
4995
|
*
|
|
@@ -5047,6 +5089,24 @@ interface IMembershipRepository {
|
|
|
5047
5089
|
* @param params - The membership key, the roles judged, owner role and audit event.
|
|
5048
5090
|
*/
|
|
5049
5091
|
remove(params: RemoveMembershipParams): Promise<MemberChangeResult>;
|
|
5092
|
+
/**
|
|
5093
|
+
* Removes every membership of an account, in every membership status and in every workspace
|
|
5094
|
+
* status, persisting one `audit` event per removed membership in the same transaction.
|
|
5095
|
+
*
|
|
5096
|
+
* For the host that is about to delete or anonymise a user. `listForUser` shows only active
|
|
5097
|
+
* memberships of active workspaces, so only the repository can find the rest.
|
|
5098
|
+
*
|
|
5099
|
+
* The last-owner rule is decided inside the transaction: when the account is the only active
|
|
5100
|
+
* `ownerRole` holder of a workspace that is not `pending_deletion` or `deleted`, nothing is
|
|
5101
|
+
* removed, no audit row is written and the answer names those workspaces. A workspace pending
|
|
5102
|
+
* deletion does not block: no one can finalize it early, and its owner must not wait out the
|
|
5103
|
+
* grace period to delete their account. Removing the owner's membership there means the
|
|
5104
|
+
* workspace can no longer be restored, and it is deleted when its grace period ends.
|
|
5105
|
+
*
|
|
5106
|
+
* @param params - The tenant, the account, the owner role and the event template.
|
|
5107
|
+
* @returns The removed memberships, or `'last_owner'` with the ids of the workspaces that block.
|
|
5108
|
+
*/
|
|
5109
|
+
removeAllForUser(params: RemoveAllMembershipsParams): Promise<RemoveAllMembershipsResult>;
|
|
5050
5110
|
/**
|
|
5051
5111
|
* Hands ownership from one member to another in one transaction, persisting `audit` with it.
|
|
5052
5112
|
*
|
|
@@ -12211,6 +12271,23 @@ declare class AuthTokenVerifierService {
|
|
|
12211
12271
|
interface MyWorkspaces extends MembershipPage<MembershipWithWorkspace> {
|
|
12212
12272
|
lastActiveWorkspaceId: string | null;
|
|
12213
12273
|
}
|
|
12274
|
+
/**
|
|
12275
|
+
* Thrown by {@link MembershipService.removeAllForUser} when the memberships were removed but the
|
|
12276
|
+
* cached access of some of them could not be dropped. The removal is committed, so calling it again
|
|
12277
|
+
* finds nothing to remove: the host re-runs `WorkspaceAccessService.invalidateMembership` for each
|
|
12278
|
+
* entry of {@link MembershipBumpFailedError.failed}, or waits out `membershipCacheTtlSeconds`.
|
|
12279
|
+
*/
|
|
12280
|
+
declare class MembershipBumpFailedError extends Error {
|
|
12281
|
+
readonly removed: readonly RemovedMembership[];
|
|
12282
|
+
readonly failed: readonly RemovedMembership[];
|
|
12283
|
+
readonly cause: unknown;
|
|
12284
|
+
/**
|
|
12285
|
+
* @param removed - Every membership the removal deleted.
|
|
12286
|
+
* @param failed - The ones whose cached access could not be dropped.
|
|
12287
|
+
* @param cause - The first error a bump failed with.
|
|
12288
|
+
*/
|
|
12289
|
+
constructor(removed: readonly RemovedMembership[], failed: readonly RemovedMembership[], cause: unknown);
|
|
12290
|
+
}
|
|
12214
12291
|
/**
|
|
12215
12292
|
* Changes who belongs to a workspace and what they may do there.
|
|
12216
12293
|
*
|
|
@@ -12279,6 +12356,27 @@ declare class MembershipService {
|
|
|
12279
12356
|
cursor?: string;
|
|
12280
12357
|
limit?: number;
|
|
12281
12358
|
}): Promise<MembershipPage<AuthWorkspace>>;
|
|
12359
|
+
/**
|
|
12360
|
+
* Removes every membership of an account that is about to be deleted or anonymised: in every
|
|
12361
|
+
* membership status and every workspace, with one `member.removed` event per removal and the
|
|
12362
|
+
* cached access of each dropped.
|
|
12363
|
+
*
|
|
12364
|
+
* Refuses while the account is the only owner of an active or suspended workspace, so the host can
|
|
12365
|
+
* transfer ownership or schedule deletion first. A workspace pending deletion does not block:
|
|
12366
|
+
* no one can finalize it early, so the owner's membership there is removed too, the workspace can
|
|
12367
|
+
* no longer be restored, and the host's finalize job deletes it when its grace period ends.
|
|
12368
|
+
*
|
|
12369
|
+
* @param tenantId - The account's tenant.
|
|
12370
|
+
* @param userId - The account.
|
|
12371
|
+
* @param actorUserId - Who authorizes the deletion: the account, an administrator, or `null` for a
|
|
12372
|
+
* job. No workspace role does, so none is checked.
|
|
12373
|
+
* @param context - Request metadata for the hook.
|
|
12374
|
+
* @returns The memberships removed.
|
|
12375
|
+
* @throws {AuthException} `auth.last_owner`, with `details.workspaces`, while a workspace would be
|
|
12376
|
+
* left without an owner; nothing is removed.
|
|
12377
|
+
* @throws {MembershipBumpFailedError} When the removal committed but a cache bump failed.
|
|
12378
|
+
*/
|
|
12379
|
+
removeAllForUser(tenantId: string, userId: string, actorUserId: string | null, context: HookContext): Promise<RemovedMembership[]>;
|
|
12282
12380
|
/**
|
|
12283
12381
|
* Changes a member's role.
|
|
12284
12382
|
*
|
|
@@ -12394,6 +12492,11 @@ declare class MembershipService {
|
|
|
12394
12492
|
* only on a role it includes and does not itself hold.
|
|
12395
12493
|
*/
|
|
12396
12494
|
private outranks;
|
|
12495
|
+
/**
|
|
12496
|
+
* The workspaces that stop an account deletion: those the account alone owns, except the ones
|
|
12497
|
+
* pending deletion or deleted. Stops reading pages once a full page of them is known.
|
|
12498
|
+
*/
|
|
12499
|
+
private soleOwnedBlocking;
|
|
12397
12500
|
private removeWith;
|
|
12398
12501
|
/**
|
|
12399
12502
|
* Turns a guarded write's outcome into an error, or ends the affected members' cached access.
|
|
@@ -14273,5 +14376,5 @@ declare class WorkspaceInvitationService {
|
|
|
14273
14376
|
private activeWorkspace;
|
|
14274
14377
|
}
|
|
14275
14378
|
|
|
14276
|
-
export { ALLOW_PENDING_WORKSPACE_KEY, ANY_WORKSPACE_MEMBER, API_KEY_MAX_LABEL_LENGTH, API_KEY_MAX_OVERLAP_SECONDS, AUTH_EMAIL_KINDS, AUTH_ERROR_CODES, AUTH_ERROR_MESSAGES, AUTH_ERROR_STATUS, AUTH_SECURITY_SCHEMES, AUTH_THROTTLE_CONFIGS, AcceptInvitationDto, AccountStatusService, AllowAllBreachChecker, AllowPendingWorkspace, ApiKeyGuard, ApiKeyScopes, ApiKeyService, AuthException, AuthExceptionFilter, AuthRateLimit, AuthRateLimitGuard, AuthRevocationService, AuthService, AuthTokenVerifierService, Authenticated, BYMAX_AUTH_API_KEY_CLOCK, BYMAX_AUTH_API_KEY_REPOSITORY, BYMAX_AUTH_BREACH_CHECKER, BYMAX_AUTH_EMAIL_PROVIDER, BYMAX_AUTH_HOOKS, BYMAX_AUTH_MEMBERSHIP_REPOSITORY, BYMAX_AUTH_OPTIONS, BYMAX_AUTH_PLATFORM_USER_REPOSITORY, BYMAX_AUTH_REDIS_CLIENT, BYMAX_AUTH_USER_REPOSITORY, BYMAX_AUTH_WORKSPACE_REPOSITORY, BruteForceService, BymaxAuthModule, ChangePasswordDto, CommonPasswordChecker, CreateInvitationDto, CurrentApiKey, CurrentUser, CurrentWorkspace, CurrentWsWorkspace, DefaultAuthEmailProvider, EmailChangeService, ForgotPasswordDto, HibpBreachChecker, IS_PUBLIC_KEY, InvitationService, JwtAuthGuard, JwtPlatformGuard, LoginDto, MembershipService, MfaChallengeDto, MfaDisableDto, MfaRegenerateRecoveryCodesDto, MfaRequiredGuard, MfaService, MfaVerifyDto, NoOpAuthHooks, NoOpEmailProvider, OAuthService, OptionalAuthGuard, OtpService, PLATFORM_ROLES_KEY, PasswordResetService, PlatformAuthService, PlatformLoginDto, PlatformRoles, PlatformRolesGuard, Public, ROLES_KEY, ReauthenticationService, RegisterDto, RequestEncoding, RequestEncodingGuard, ResendOtpDto, ResendVerificationDto, ResetPasswordDto, Roles, RolesGuard, SKIP_MFA_KEY, SelfOrAdminGuard, ServiceKey, SessionService, SkipMfa, TokenDeliveryService, TrustedOriginGuard, UserStatusGuard, VerifyEmailDto, VerifyOtpDto, WORKSPACE_PERMISSION_KEY, WORKSPACE_ROLES_KEY, WS_TICKET_TTL_SECONDS, WorkspaceAccessService, WorkspaceActionsService, WorkspaceCallerService, WorkspaceGuard, WorkspaceInvitationService, WorkspacePermission, WorkspaceRoles, WorkspaceService, WsAuthExceptionFilter, WsJwtGuard, WsTicketService, WsWorkspaceGuard, authDocumentSecurity, createAuthValidationPipe, decodeWorkspaceScopedName, decrypt, describeChannelStatus, describeError, encrypt, generateSecureToken, hasRole, hmacSha256, redactSecrets, reduceToBaseWord, sanitizeHeaders, sha256, sleep, stampJobContext, timingSafeCompare, workspaceScopedName };
|
|
14277
|
-
export type { AcceptedInvitation, AcceptedSignup, ActingMember, ApiKeyAccessEvent, ApiKeyClock, ApiKeyDenyReason, ApiKeyPrincipal, AuthApiKey, AuthApiKeySummary, AuthDocumentSecurityParams, AuthEmailCatalogue, AuthEmailContext, AuthEmailKind, AuthEmailMessage, AuthEmailSink, AuthErrorCode, AuthFieldError, AuthGuardFamily, AuthMembership, AuthModuleAsyncOptions, AuthPlane, AuthPlatformUser, AuthRateLimitWindow, AuthResult, AuthUser, AuthWorkspace, AuthenticatedRequest, BearerAuthResponse, BeforeRegisterResult, BeforeWorkspaceCreateResult, BootstrapInvitationRecord, BothAuthResponse, BymaxAuthModuleOptions, BymaxAuthRateLimitOptions, ChangeMembershipRoleParams, ClientIpSource, CookieAuthResponse, CountOwnedParams, CreateMembershipParams, CreateMembershipResult, CreateSessionParams, CreateUserData, CreateWithOAuthData, CreateWorkspaceResult, CreateWorkspaceWithOwnerParams, CurrentWorkspaceContext, DashboardJwtPayload, DefaultAuthEmailProviderOptions, DeliveryErrorPolicy, DeliveryErrorPolicyMap, FinalizeResult, FindUserByEmailParams, FindUserByOAuthIdParams, GuardedWriteResult, HookContext, IApiKeyRepository, IAuthHooks, IEmailProvider, IMembershipRepository, IPasswordBreachChecker, IPlatformUserRepository, IUserRepository, IWorkspaceRepository, InviteData, IssueApiKeyInput, IssuedApiKey, LastActiveWorkspaceRef, LinkOAuthParams, ListMembershipsForUserParams, ListMembershipsForWorkspaceParams, ListSessionsParams, ListSoleOwnedParams, LiveSessionParams, MemberChangeResult, MemberInvitationRecord, MembershipPage, MembershipRef, MembershipStatus, MembershipWithWorkspace, MfaChallengeResult, MfaSetupResult, MfaTempPayload, MyWorkspaces, OAuthLoginResult, OAuthMfaChallengeResult, OAuthProfile, OAuthProviderPlugin, OpenApiSecurityRequirement, PlatformAuthResult, PlatformAuthenticatedRequest, PlatformBearerAuthResponse, PlatformJwtPayload, RegistrationMode, RemoveMembershipParams, RenameWorkspaceParams, RenameWorkspaceResult, RequestEncodingPolicy, ResolvedOptions, ResolvedWorkspaceMember, RevocableTokenPayload, RevokeAllExceptCurrentParams, RevokeAllSessionsParams, RevokeSessionParams, RotateApiKeyInput, RotatedTokenResult, SafeAuthPlatformUser, SafeAuthUser, ScheduledDeletion, SessionAlertInfo, SessionInfo, SetLastActiveWorkspaceParams, SignupRequest, StoredWorkspaceInvitation, TenantResolverRequest, TenantScopedUserRef, TransferOwnershipParams, TransferOwnershipResult, UpdateEmailParams, UpdateEmailVerifiedParams, UpdateMfaData, UpdateMfaParams, UpdatePasswordParams, UpdatePlatformMfaData, UpdateStatusParams, UpdateWorkspaceStatusParams, UpdateWorkspaceStatusResult, VerifiedAccessToken, VerifiedWorkspaceAccessToken, VerifyAccessTokenOptions, WorkspaceAccess, WorkspaceAccessView, WorkspaceAction, WorkspaceActor, WorkspaceAuditEvent, WorkspaceCheck, WorkspaceInvitationPreview, WorkspaceInvitationView, WorkspaceInviteData, WorkspaceJobContext, WorkspaceOptions, WorkspacePermissionOptions, WorkspaceRef, WorkspaceRequest, WorkspaceRoleList, WorkspaceStatus, WsTicketSnapshot };
|
|
14379
|
+
export { ALLOW_PENDING_WORKSPACE_KEY, ANY_WORKSPACE_MEMBER, API_KEY_MAX_LABEL_LENGTH, API_KEY_MAX_OVERLAP_SECONDS, AUTH_EMAIL_KINDS, AUTH_ERROR_CODES, AUTH_ERROR_MESSAGES, AUTH_ERROR_STATUS, AUTH_SECURITY_SCHEMES, AUTH_THROTTLE_CONFIGS, AcceptInvitationDto, AccountStatusService, AllowAllBreachChecker, AllowPendingWorkspace, ApiKeyGuard, ApiKeyScopes, ApiKeyService, AuthException, AuthExceptionFilter, AuthRateLimit, AuthRateLimitGuard, AuthRevocationService, AuthService, AuthTokenVerifierService, Authenticated, BYMAX_AUTH_API_KEY_CLOCK, BYMAX_AUTH_API_KEY_REPOSITORY, BYMAX_AUTH_BREACH_CHECKER, BYMAX_AUTH_EMAIL_PROVIDER, BYMAX_AUTH_HOOKS, BYMAX_AUTH_MEMBERSHIP_REPOSITORY, BYMAX_AUTH_OPTIONS, BYMAX_AUTH_PLATFORM_USER_REPOSITORY, BYMAX_AUTH_REDIS_CLIENT, BYMAX_AUTH_USER_REPOSITORY, BYMAX_AUTH_WORKSPACE_REPOSITORY, BruteForceService, BymaxAuthModule, ChangePasswordDto, CommonPasswordChecker, CreateInvitationDto, CurrentApiKey, CurrentUser, CurrentWorkspace, CurrentWsWorkspace, DefaultAuthEmailProvider, EmailChangeService, ForgotPasswordDto, HibpBreachChecker, IS_PUBLIC_KEY, InvitationService, JwtAuthGuard, JwtPlatformGuard, LoginDto, MembershipBumpFailedError, MembershipService, MfaChallengeDto, MfaDisableDto, MfaRegenerateRecoveryCodesDto, MfaRequiredGuard, MfaService, MfaVerifyDto, NoOpAuthHooks, NoOpEmailProvider, OAuthService, OptionalAuthGuard, OtpService, PLATFORM_ROLES_KEY, PasswordResetService, PlatformAuthService, PlatformLoginDto, PlatformRoles, PlatformRolesGuard, Public, ROLES_KEY, ReauthenticationService, RegisterDto, RequestEncoding, RequestEncodingGuard, ResendOtpDto, ResendVerificationDto, ResetPasswordDto, Roles, RolesGuard, SKIP_MFA_KEY, SelfOrAdminGuard, ServiceKey, SessionService, SkipMfa, TokenDeliveryService, TrustedOriginGuard, UserStatusGuard, VerifyEmailDto, VerifyOtpDto, WORKSPACE_PERMISSION_KEY, WORKSPACE_ROLES_KEY, WS_TICKET_TTL_SECONDS, WorkspaceAccessService, WorkspaceActionsService, WorkspaceCallerService, WorkspaceGuard, WorkspaceInvitationService, WorkspacePermission, WorkspaceRoles, WorkspaceService, WsAuthExceptionFilter, WsJwtGuard, WsTicketService, WsWorkspaceGuard, authDocumentSecurity, createAuthValidationPipe, decodeWorkspaceScopedName, decrypt, describeChannelStatus, describeError, encrypt, generateSecureToken, hasRole, hmacSha256, redactSecrets, reduceToBaseWord, sanitizeHeaders, sha256, sleep, stampJobContext, timingSafeCompare, workspaceScopedName };
|
|
14380
|
+
export type { AcceptedInvitation, AcceptedSignup, AccountRemovalAudit, ActingMember, ApiKeyAccessEvent, ApiKeyClock, ApiKeyDenyReason, ApiKeyPrincipal, AuthApiKey, AuthApiKeySummary, AuthDocumentSecurityParams, AuthEmailCatalogue, AuthEmailContext, AuthEmailKind, AuthEmailMessage, AuthEmailSink, AuthErrorCode, AuthFieldError, AuthGuardFamily, AuthMembership, AuthModuleAsyncOptions, AuthPlane, AuthPlatformUser, AuthRateLimitWindow, AuthResult, AuthUser, AuthWorkspace, AuthenticatedRequest, BearerAuthResponse, BeforeRegisterResult, BeforeWorkspaceCreateResult, BootstrapInvitationRecord, BothAuthResponse, BymaxAuthModuleOptions, BymaxAuthRateLimitOptions, ChangeMembershipRoleParams, ClientIpSource, CookieAuthResponse, CountOwnedParams, CreateMembershipParams, CreateMembershipResult, CreateSessionParams, CreateUserData, CreateWithOAuthData, CreateWorkspaceResult, CreateWorkspaceWithOwnerParams, CurrentWorkspaceContext, DashboardJwtPayload, DefaultAuthEmailProviderOptions, DeliveryErrorPolicy, DeliveryErrorPolicyMap, FinalizeResult, FindUserByEmailParams, FindUserByOAuthIdParams, GuardedWriteResult, HookContext, IApiKeyRepository, IAuthHooks, IEmailProvider, IMembershipRepository, IPasswordBreachChecker, IPlatformUserRepository, IUserRepository, IWorkspaceRepository, InviteData, IssueApiKeyInput, IssuedApiKey, LastActiveWorkspaceRef, LinkOAuthParams, ListMembershipsForUserParams, ListMembershipsForWorkspaceParams, ListSessionsParams, ListSoleOwnedParams, LiveSessionParams, MemberChangeResult, MemberInvitationRecord, MembershipPage, MembershipRef, MembershipStatus, MembershipWithWorkspace, MfaChallengeResult, MfaSetupResult, MfaTempPayload, MyWorkspaces, OAuthLoginResult, OAuthMfaChallengeResult, OAuthProfile, OAuthProviderPlugin, OpenApiSecurityRequirement, PlatformAuthResult, PlatformAuthenticatedRequest, PlatformBearerAuthResponse, PlatformJwtPayload, RegistrationMode, RemoveAllMembershipsParams, RemoveAllMembershipsResult, RemoveMembershipParams, RemovedMembership, RenameWorkspaceParams, RenameWorkspaceResult, RequestEncodingPolicy, ResolvedOptions, ResolvedWorkspaceMember, RevocableTokenPayload, RevokeAllExceptCurrentParams, RevokeAllSessionsParams, RevokeSessionParams, RotateApiKeyInput, RotatedTokenResult, SafeAuthPlatformUser, SafeAuthUser, ScheduledDeletion, SessionAlertInfo, SessionInfo, SetLastActiveWorkspaceParams, SignupRequest, StoredWorkspaceInvitation, TenantResolverRequest, TenantScopedUserRef, TransferOwnershipParams, TransferOwnershipResult, UpdateEmailParams, UpdateEmailVerifiedParams, UpdateMfaData, UpdateMfaParams, UpdatePasswordParams, UpdatePlatformMfaData, UpdateStatusParams, UpdateWorkspaceStatusParams, UpdateWorkspaceStatusResult, VerifiedAccessToken, VerifiedWorkspaceAccessToken, VerifyAccessTokenOptions, WorkspaceAccess, WorkspaceAccessView, WorkspaceAction, WorkspaceActor, WorkspaceAuditEvent, WorkspaceCheck, WorkspaceInvitationPreview, WorkspaceInvitationView, WorkspaceInviteData, WorkspaceJobContext, WorkspaceOptions, WorkspacePermissionOptions, WorkspaceRef, WorkspaceRequest, WorkspaceRoleList, WorkspaceStatus, WsTicketSnapshot };
|
package/dist/server/index.d.ts
CHANGED
|
@@ -4948,6 +4948,48 @@ type GuardedWriteResult = 'ok' | 'not_found' | 'last_owner';
|
|
|
4948
4948
|
type MemberChangeResult = GuardedWriteResult | 'actor_changed';
|
|
4949
4949
|
/** Outcome of {@link IMembershipRepository.transferOwnership}. */
|
|
4950
4950
|
type TransferOwnershipResult = GuardedWriteResult | 'target_not_member';
|
|
4951
|
+
/**
|
|
4952
|
+
* The event persisted for each membership {@link IMembershipRepository.removeAllForUser} deletes.
|
|
4953
|
+
* The repository stores one `member.removed` event per removed membership, naming that
|
|
4954
|
+
* membership's workspace, and nothing else is added to it.
|
|
4955
|
+
*/
|
|
4956
|
+
interface AccountRemovalAudit {
|
|
4957
|
+
type: 'member.removed';
|
|
4958
|
+
/** The tenant of the account. */
|
|
4959
|
+
tenantId: string;
|
|
4960
|
+
/** Who authorized the removal: the member themselves, an administrator, or `null` for a job. */
|
|
4961
|
+
actorUserId: string | null;
|
|
4962
|
+
/** The account whose memberships are removed. */
|
|
4963
|
+
userId: string;
|
|
4964
|
+
/** When the removal was decided, as an ISO-8601 string. */
|
|
4965
|
+
at: string;
|
|
4966
|
+
}
|
|
4967
|
+
/** Input to {@link IMembershipRepository.removeAllForUser}. */
|
|
4968
|
+
interface RemoveAllMembershipsParams {
|
|
4969
|
+
/** The tenant of the account. */
|
|
4970
|
+
tenantId: string;
|
|
4971
|
+
/** The account whose memberships are removed. */
|
|
4972
|
+
userId: string;
|
|
4973
|
+
/** The role that owns a workspace, so the last-owner rule can be decided with the write. */
|
|
4974
|
+
ownerRole: string;
|
|
4975
|
+
/** The event to persist for each membership removed. */
|
|
4976
|
+
audit: AccountRemovalAudit;
|
|
4977
|
+
}
|
|
4978
|
+
/** One membership an account removal deleted. */
|
|
4979
|
+
interface RemovedMembership {
|
|
4980
|
+
/** The workspace the membership was in. */
|
|
4981
|
+
workspaceId: string;
|
|
4982
|
+
/** The role the account held there. */
|
|
4983
|
+
role: string;
|
|
4984
|
+
}
|
|
4985
|
+
/** Outcome of {@link IMembershipRepository.removeAllForUser}. */
|
|
4986
|
+
type RemoveAllMembershipsResult = {
|
|
4987
|
+
result: 'ok';
|
|
4988
|
+
removed: RemovedMembership[];
|
|
4989
|
+
} | {
|
|
4990
|
+
result: 'last_owner';
|
|
4991
|
+
workspaceIds: string[];
|
|
4992
|
+
};
|
|
4951
4993
|
/**
|
|
4952
4994
|
* The membership port a host implements.
|
|
4953
4995
|
*
|
|
@@ -5047,6 +5089,24 @@ interface IMembershipRepository {
|
|
|
5047
5089
|
* @param params - The membership key, the roles judged, owner role and audit event.
|
|
5048
5090
|
*/
|
|
5049
5091
|
remove(params: RemoveMembershipParams): Promise<MemberChangeResult>;
|
|
5092
|
+
/**
|
|
5093
|
+
* Removes every membership of an account, in every membership status and in every workspace
|
|
5094
|
+
* status, persisting one `audit` event per removed membership in the same transaction.
|
|
5095
|
+
*
|
|
5096
|
+
* For the host that is about to delete or anonymise a user. `listForUser` shows only active
|
|
5097
|
+
* memberships of active workspaces, so only the repository can find the rest.
|
|
5098
|
+
*
|
|
5099
|
+
* The last-owner rule is decided inside the transaction: when the account is the only active
|
|
5100
|
+
* `ownerRole` holder of a workspace that is not `pending_deletion` or `deleted`, nothing is
|
|
5101
|
+
* removed, no audit row is written and the answer names those workspaces. A workspace pending
|
|
5102
|
+
* deletion does not block: no one can finalize it early, and its owner must not wait out the
|
|
5103
|
+
* grace period to delete their account. Removing the owner's membership there means the
|
|
5104
|
+
* workspace can no longer be restored, and it is deleted when its grace period ends.
|
|
5105
|
+
*
|
|
5106
|
+
* @param params - The tenant, the account, the owner role and the event template.
|
|
5107
|
+
* @returns The removed memberships, or `'last_owner'` with the ids of the workspaces that block.
|
|
5108
|
+
*/
|
|
5109
|
+
removeAllForUser(params: RemoveAllMembershipsParams): Promise<RemoveAllMembershipsResult>;
|
|
5050
5110
|
/**
|
|
5051
5111
|
* Hands ownership from one member to another in one transaction, persisting `audit` with it.
|
|
5052
5112
|
*
|
|
@@ -12211,6 +12271,23 @@ declare class AuthTokenVerifierService {
|
|
|
12211
12271
|
interface MyWorkspaces extends MembershipPage<MembershipWithWorkspace> {
|
|
12212
12272
|
lastActiveWorkspaceId: string | null;
|
|
12213
12273
|
}
|
|
12274
|
+
/**
|
|
12275
|
+
* Thrown by {@link MembershipService.removeAllForUser} when the memberships were removed but the
|
|
12276
|
+
* cached access of some of them could not be dropped. The removal is committed, so calling it again
|
|
12277
|
+
* finds nothing to remove: the host re-runs `WorkspaceAccessService.invalidateMembership` for each
|
|
12278
|
+
* entry of {@link MembershipBumpFailedError.failed}, or waits out `membershipCacheTtlSeconds`.
|
|
12279
|
+
*/
|
|
12280
|
+
declare class MembershipBumpFailedError extends Error {
|
|
12281
|
+
readonly removed: readonly RemovedMembership[];
|
|
12282
|
+
readonly failed: readonly RemovedMembership[];
|
|
12283
|
+
readonly cause: unknown;
|
|
12284
|
+
/**
|
|
12285
|
+
* @param removed - Every membership the removal deleted.
|
|
12286
|
+
* @param failed - The ones whose cached access could not be dropped.
|
|
12287
|
+
* @param cause - The first error a bump failed with.
|
|
12288
|
+
*/
|
|
12289
|
+
constructor(removed: readonly RemovedMembership[], failed: readonly RemovedMembership[], cause: unknown);
|
|
12290
|
+
}
|
|
12214
12291
|
/**
|
|
12215
12292
|
* Changes who belongs to a workspace and what they may do there.
|
|
12216
12293
|
*
|
|
@@ -12279,6 +12356,27 @@ declare class MembershipService {
|
|
|
12279
12356
|
cursor?: string;
|
|
12280
12357
|
limit?: number;
|
|
12281
12358
|
}): Promise<MembershipPage<AuthWorkspace>>;
|
|
12359
|
+
/**
|
|
12360
|
+
* Removes every membership of an account that is about to be deleted or anonymised: in every
|
|
12361
|
+
* membership status and every workspace, with one `member.removed` event per removal and the
|
|
12362
|
+
* cached access of each dropped.
|
|
12363
|
+
*
|
|
12364
|
+
* Refuses while the account is the only owner of an active or suspended workspace, so the host can
|
|
12365
|
+
* transfer ownership or schedule deletion first. A workspace pending deletion does not block:
|
|
12366
|
+
* no one can finalize it early, so the owner's membership there is removed too, the workspace can
|
|
12367
|
+
* no longer be restored, and the host's finalize job deletes it when its grace period ends.
|
|
12368
|
+
*
|
|
12369
|
+
* @param tenantId - The account's tenant.
|
|
12370
|
+
* @param userId - The account.
|
|
12371
|
+
* @param actorUserId - Who authorizes the deletion: the account, an administrator, or `null` for a
|
|
12372
|
+
* job. No workspace role does, so none is checked.
|
|
12373
|
+
* @param context - Request metadata for the hook.
|
|
12374
|
+
* @returns The memberships removed.
|
|
12375
|
+
* @throws {AuthException} `auth.last_owner`, with `details.workspaces`, while a workspace would be
|
|
12376
|
+
* left without an owner; nothing is removed.
|
|
12377
|
+
* @throws {MembershipBumpFailedError} When the removal committed but a cache bump failed.
|
|
12378
|
+
*/
|
|
12379
|
+
removeAllForUser(tenantId: string, userId: string, actorUserId: string | null, context: HookContext): Promise<RemovedMembership[]>;
|
|
12282
12380
|
/**
|
|
12283
12381
|
* Changes a member's role.
|
|
12284
12382
|
*
|
|
@@ -12394,6 +12492,11 @@ declare class MembershipService {
|
|
|
12394
12492
|
* only on a role it includes and does not itself hold.
|
|
12395
12493
|
*/
|
|
12396
12494
|
private outranks;
|
|
12495
|
+
/**
|
|
12496
|
+
* The workspaces that stop an account deletion: those the account alone owns, except the ones
|
|
12497
|
+
* pending deletion or deleted. Stops reading pages once a full page of them is known.
|
|
12498
|
+
*/
|
|
12499
|
+
private soleOwnedBlocking;
|
|
12397
12500
|
private removeWith;
|
|
12398
12501
|
/**
|
|
12399
12502
|
* Turns a guarded write's outcome into an error, or ends the affected members' cached access.
|
|
@@ -14273,5 +14376,5 @@ declare class WorkspaceInvitationService {
|
|
|
14273
14376
|
private activeWorkspace;
|
|
14274
14377
|
}
|
|
14275
14378
|
|
|
14276
|
-
export { ALLOW_PENDING_WORKSPACE_KEY, ANY_WORKSPACE_MEMBER, API_KEY_MAX_LABEL_LENGTH, API_KEY_MAX_OVERLAP_SECONDS, AUTH_EMAIL_KINDS, AUTH_ERROR_CODES, AUTH_ERROR_MESSAGES, AUTH_ERROR_STATUS, AUTH_SECURITY_SCHEMES, AUTH_THROTTLE_CONFIGS, AcceptInvitationDto, AccountStatusService, AllowAllBreachChecker, AllowPendingWorkspace, ApiKeyGuard, ApiKeyScopes, ApiKeyService, AuthException, AuthExceptionFilter, AuthRateLimit, AuthRateLimitGuard, AuthRevocationService, AuthService, AuthTokenVerifierService, Authenticated, BYMAX_AUTH_API_KEY_CLOCK, BYMAX_AUTH_API_KEY_REPOSITORY, BYMAX_AUTH_BREACH_CHECKER, BYMAX_AUTH_EMAIL_PROVIDER, BYMAX_AUTH_HOOKS, BYMAX_AUTH_MEMBERSHIP_REPOSITORY, BYMAX_AUTH_OPTIONS, BYMAX_AUTH_PLATFORM_USER_REPOSITORY, BYMAX_AUTH_REDIS_CLIENT, BYMAX_AUTH_USER_REPOSITORY, BYMAX_AUTH_WORKSPACE_REPOSITORY, BruteForceService, BymaxAuthModule, ChangePasswordDto, CommonPasswordChecker, CreateInvitationDto, CurrentApiKey, CurrentUser, CurrentWorkspace, CurrentWsWorkspace, DefaultAuthEmailProvider, EmailChangeService, ForgotPasswordDto, HibpBreachChecker, IS_PUBLIC_KEY, InvitationService, JwtAuthGuard, JwtPlatformGuard, LoginDto, MembershipService, MfaChallengeDto, MfaDisableDto, MfaRegenerateRecoveryCodesDto, MfaRequiredGuard, MfaService, MfaVerifyDto, NoOpAuthHooks, NoOpEmailProvider, OAuthService, OptionalAuthGuard, OtpService, PLATFORM_ROLES_KEY, PasswordResetService, PlatformAuthService, PlatformLoginDto, PlatformRoles, PlatformRolesGuard, Public, ROLES_KEY, ReauthenticationService, RegisterDto, RequestEncoding, RequestEncodingGuard, ResendOtpDto, ResendVerificationDto, ResetPasswordDto, Roles, RolesGuard, SKIP_MFA_KEY, SelfOrAdminGuard, ServiceKey, SessionService, SkipMfa, TokenDeliveryService, TrustedOriginGuard, UserStatusGuard, VerifyEmailDto, VerifyOtpDto, WORKSPACE_PERMISSION_KEY, WORKSPACE_ROLES_KEY, WS_TICKET_TTL_SECONDS, WorkspaceAccessService, WorkspaceActionsService, WorkspaceCallerService, WorkspaceGuard, WorkspaceInvitationService, WorkspacePermission, WorkspaceRoles, WorkspaceService, WsAuthExceptionFilter, WsJwtGuard, WsTicketService, WsWorkspaceGuard, authDocumentSecurity, createAuthValidationPipe, decodeWorkspaceScopedName, decrypt, describeChannelStatus, describeError, encrypt, generateSecureToken, hasRole, hmacSha256, redactSecrets, reduceToBaseWord, sanitizeHeaders, sha256, sleep, stampJobContext, timingSafeCompare, workspaceScopedName };
|
|
14277
|
-
export type { AcceptedInvitation, AcceptedSignup, ActingMember, ApiKeyAccessEvent, ApiKeyClock, ApiKeyDenyReason, ApiKeyPrincipal, AuthApiKey, AuthApiKeySummary, AuthDocumentSecurityParams, AuthEmailCatalogue, AuthEmailContext, AuthEmailKind, AuthEmailMessage, AuthEmailSink, AuthErrorCode, AuthFieldError, AuthGuardFamily, AuthMembership, AuthModuleAsyncOptions, AuthPlane, AuthPlatformUser, AuthRateLimitWindow, AuthResult, AuthUser, AuthWorkspace, AuthenticatedRequest, BearerAuthResponse, BeforeRegisterResult, BeforeWorkspaceCreateResult, BootstrapInvitationRecord, BothAuthResponse, BymaxAuthModuleOptions, BymaxAuthRateLimitOptions, ChangeMembershipRoleParams, ClientIpSource, CookieAuthResponse, CountOwnedParams, CreateMembershipParams, CreateMembershipResult, CreateSessionParams, CreateUserData, CreateWithOAuthData, CreateWorkspaceResult, CreateWorkspaceWithOwnerParams, CurrentWorkspaceContext, DashboardJwtPayload, DefaultAuthEmailProviderOptions, DeliveryErrorPolicy, DeliveryErrorPolicyMap, FinalizeResult, FindUserByEmailParams, FindUserByOAuthIdParams, GuardedWriteResult, HookContext, IApiKeyRepository, IAuthHooks, IEmailProvider, IMembershipRepository, IPasswordBreachChecker, IPlatformUserRepository, IUserRepository, IWorkspaceRepository, InviteData, IssueApiKeyInput, IssuedApiKey, LastActiveWorkspaceRef, LinkOAuthParams, ListMembershipsForUserParams, ListMembershipsForWorkspaceParams, ListSessionsParams, ListSoleOwnedParams, LiveSessionParams, MemberChangeResult, MemberInvitationRecord, MembershipPage, MembershipRef, MembershipStatus, MembershipWithWorkspace, MfaChallengeResult, MfaSetupResult, MfaTempPayload, MyWorkspaces, OAuthLoginResult, OAuthMfaChallengeResult, OAuthProfile, OAuthProviderPlugin, OpenApiSecurityRequirement, PlatformAuthResult, PlatformAuthenticatedRequest, PlatformBearerAuthResponse, PlatformJwtPayload, RegistrationMode, RemoveMembershipParams, RenameWorkspaceParams, RenameWorkspaceResult, RequestEncodingPolicy, ResolvedOptions, ResolvedWorkspaceMember, RevocableTokenPayload, RevokeAllExceptCurrentParams, RevokeAllSessionsParams, RevokeSessionParams, RotateApiKeyInput, RotatedTokenResult, SafeAuthPlatformUser, SafeAuthUser, ScheduledDeletion, SessionAlertInfo, SessionInfo, SetLastActiveWorkspaceParams, SignupRequest, StoredWorkspaceInvitation, TenantResolverRequest, TenantScopedUserRef, TransferOwnershipParams, TransferOwnershipResult, UpdateEmailParams, UpdateEmailVerifiedParams, UpdateMfaData, UpdateMfaParams, UpdatePasswordParams, UpdatePlatformMfaData, UpdateStatusParams, UpdateWorkspaceStatusParams, UpdateWorkspaceStatusResult, VerifiedAccessToken, VerifiedWorkspaceAccessToken, VerifyAccessTokenOptions, WorkspaceAccess, WorkspaceAccessView, WorkspaceAction, WorkspaceActor, WorkspaceAuditEvent, WorkspaceCheck, WorkspaceInvitationPreview, WorkspaceInvitationView, WorkspaceInviteData, WorkspaceJobContext, WorkspaceOptions, WorkspacePermissionOptions, WorkspaceRef, WorkspaceRequest, WorkspaceRoleList, WorkspaceStatus, WsTicketSnapshot };
|
|
14379
|
+
export { ALLOW_PENDING_WORKSPACE_KEY, ANY_WORKSPACE_MEMBER, API_KEY_MAX_LABEL_LENGTH, API_KEY_MAX_OVERLAP_SECONDS, AUTH_EMAIL_KINDS, AUTH_ERROR_CODES, AUTH_ERROR_MESSAGES, AUTH_ERROR_STATUS, AUTH_SECURITY_SCHEMES, AUTH_THROTTLE_CONFIGS, AcceptInvitationDto, AccountStatusService, AllowAllBreachChecker, AllowPendingWorkspace, ApiKeyGuard, ApiKeyScopes, ApiKeyService, AuthException, AuthExceptionFilter, AuthRateLimit, AuthRateLimitGuard, AuthRevocationService, AuthService, AuthTokenVerifierService, Authenticated, BYMAX_AUTH_API_KEY_CLOCK, BYMAX_AUTH_API_KEY_REPOSITORY, BYMAX_AUTH_BREACH_CHECKER, BYMAX_AUTH_EMAIL_PROVIDER, BYMAX_AUTH_HOOKS, BYMAX_AUTH_MEMBERSHIP_REPOSITORY, BYMAX_AUTH_OPTIONS, BYMAX_AUTH_PLATFORM_USER_REPOSITORY, BYMAX_AUTH_REDIS_CLIENT, BYMAX_AUTH_USER_REPOSITORY, BYMAX_AUTH_WORKSPACE_REPOSITORY, BruteForceService, BymaxAuthModule, ChangePasswordDto, CommonPasswordChecker, CreateInvitationDto, CurrentApiKey, CurrentUser, CurrentWorkspace, CurrentWsWorkspace, DefaultAuthEmailProvider, EmailChangeService, ForgotPasswordDto, HibpBreachChecker, IS_PUBLIC_KEY, InvitationService, JwtAuthGuard, JwtPlatformGuard, LoginDto, MembershipBumpFailedError, MembershipService, MfaChallengeDto, MfaDisableDto, MfaRegenerateRecoveryCodesDto, MfaRequiredGuard, MfaService, MfaVerifyDto, NoOpAuthHooks, NoOpEmailProvider, OAuthService, OptionalAuthGuard, OtpService, PLATFORM_ROLES_KEY, PasswordResetService, PlatformAuthService, PlatformLoginDto, PlatformRoles, PlatformRolesGuard, Public, ROLES_KEY, ReauthenticationService, RegisterDto, RequestEncoding, RequestEncodingGuard, ResendOtpDto, ResendVerificationDto, ResetPasswordDto, Roles, RolesGuard, SKIP_MFA_KEY, SelfOrAdminGuard, ServiceKey, SessionService, SkipMfa, TokenDeliveryService, TrustedOriginGuard, UserStatusGuard, VerifyEmailDto, VerifyOtpDto, WORKSPACE_PERMISSION_KEY, WORKSPACE_ROLES_KEY, WS_TICKET_TTL_SECONDS, WorkspaceAccessService, WorkspaceActionsService, WorkspaceCallerService, WorkspaceGuard, WorkspaceInvitationService, WorkspacePermission, WorkspaceRoles, WorkspaceService, WsAuthExceptionFilter, WsJwtGuard, WsTicketService, WsWorkspaceGuard, authDocumentSecurity, createAuthValidationPipe, decodeWorkspaceScopedName, decrypt, describeChannelStatus, describeError, encrypt, generateSecureToken, hasRole, hmacSha256, redactSecrets, reduceToBaseWord, sanitizeHeaders, sha256, sleep, stampJobContext, timingSafeCompare, workspaceScopedName };
|
|
14380
|
+
export type { AcceptedInvitation, AcceptedSignup, AccountRemovalAudit, ActingMember, ApiKeyAccessEvent, ApiKeyClock, ApiKeyDenyReason, ApiKeyPrincipal, AuthApiKey, AuthApiKeySummary, AuthDocumentSecurityParams, AuthEmailCatalogue, AuthEmailContext, AuthEmailKind, AuthEmailMessage, AuthEmailSink, AuthErrorCode, AuthFieldError, AuthGuardFamily, AuthMembership, AuthModuleAsyncOptions, AuthPlane, AuthPlatformUser, AuthRateLimitWindow, AuthResult, AuthUser, AuthWorkspace, AuthenticatedRequest, BearerAuthResponse, BeforeRegisterResult, BeforeWorkspaceCreateResult, BootstrapInvitationRecord, BothAuthResponse, BymaxAuthModuleOptions, BymaxAuthRateLimitOptions, ChangeMembershipRoleParams, ClientIpSource, CookieAuthResponse, CountOwnedParams, CreateMembershipParams, CreateMembershipResult, CreateSessionParams, CreateUserData, CreateWithOAuthData, CreateWorkspaceResult, CreateWorkspaceWithOwnerParams, CurrentWorkspaceContext, DashboardJwtPayload, DefaultAuthEmailProviderOptions, DeliveryErrorPolicy, DeliveryErrorPolicyMap, FinalizeResult, FindUserByEmailParams, FindUserByOAuthIdParams, GuardedWriteResult, HookContext, IApiKeyRepository, IAuthHooks, IEmailProvider, IMembershipRepository, IPasswordBreachChecker, IPlatformUserRepository, IUserRepository, IWorkspaceRepository, InviteData, IssueApiKeyInput, IssuedApiKey, LastActiveWorkspaceRef, LinkOAuthParams, ListMembershipsForUserParams, ListMembershipsForWorkspaceParams, ListSessionsParams, ListSoleOwnedParams, LiveSessionParams, MemberChangeResult, MemberInvitationRecord, MembershipPage, MembershipRef, MembershipStatus, MembershipWithWorkspace, MfaChallengeResult, MfaSetupResult, MfaTempPayload, MyWorkspaces, OAuthLoginResult, OAuthMfaChallengeResult, OAuthProfile, OAuthProviderPlugin, OpenApiSecurityRequirement, PlatformAuthResult, PlatformAuthenticatedRequest, PlatformBearerAuthResponse, PlatformJwtPayload, RegistrationMode, RemoveAllMembershipsParams, RemoveAllMembershipsResult, RemoveMembershipParams, RemovedMembership, RenameWorkspaceParams, RenameWorkspaceResult, RequestEncodingPolicy, ResolvedOptions, ResolvedWorkspaceMember, RevocableTokenPayload, RevokeAllExceptCurrentParams, RevokeAllSessionsParams, RevokeSessionParams, RotateApiKeyInput, RotatedTokenResult, SafeAuthPlatformUser, SafeAuthUser, ScheduledDeletion, SessionAlertInfo, SessionInfo, SetLastActiveWorkspaceParams, SignupRequest, StoredWorkspaceInvitation, TenantResolverRequest, TenantScopedUserRef, TransferOwnershipParams, TransferOwnershipResult, UpdateEmailParams, UpdateEmailVerifiedParams, UpdateMfaData, UpdateMfaParams, UpdatePasswordParams, UpdatePlatformMfaData, UpdateStatusParams, UpdateWorkspaceStatusParams, UpdateWorkspaceStatusResult, VerifiedAccessToken, VerifiedWorkspaceAccessToken, VerifyAccessTokenOptions, WorkspaceAccess, WorkspaceAccessView, WorkspaceAction, WorkspaceActor, WorkspaceAuditEvent, WorkspaceCheck, WorkspaceInvitationPreview, WorkspaceInvitationView, WorkspaceInviteData, WorkspaceJobContext, WorkspaceOptions, WorkspacePermissionOptions, WorkspaceRef, WorkspaceRequest, WorkspaceRoleList, WorkspaceStatus, WsTicketSnapshot };
|
package/dist/server/index.mjs
CHANGED
|
@@ -15958,6 +15958,23 @@ function pageSize(limit) {
|
|
|
15958
15958
|
return Math.min(Math.max(limit, 1), MAX_PAGE_SIZE);
|
|
15959
15959
|
}
|
|
15960
15960
|
__name(pageSize, "pageSize");
|
|
15961
|
+
var MembershipBumpFailedError = class extends Error {
|
|
15962
|
+
static {
|
|
15963
|
+
__name(this, "MembershipBumpFailedError");
|
|
15964
|
+
}
|
|
15965
|
+
removed;
|
|
15966
|
+
failed;
|
|
15967
|
+
cause;
|
|
15968
|
+
/**
|
|
15969
|
+
* @param removed - Every membership the removal deleted.
|
|
15970
|
+
* @param failed - The ones whose cached access could not be dropped.
|
|
15971
|
+
* @param cause - The first error a bump failed with.
|
|
15972
|
+
*/
|
|
15973
|
+
constructor(removed, failed, cause) {
|
|
15974
|
+
super("The memberships were removed but their cached access could not be dropped."), this.removed = removed, this.failed = failed, this.cause = cause;
|
|
15975
|
+
this.name = "MembershipBumpFailedError";
|
|
15976
|
+
}
|
|
15977
|
+
};
|
|
15961
15978
|
var MembershipService = class {
|
|
15962
15979
|
static {
|
|
15963
15980
|
__name(this, "MembershipService");
|
|
@@ -16039,6 +16056,76 @@ var MembershipService = class {
|
|
|
16039
16056
|
});
|
|
16040
16057
|
}
|
|
16041
16058
|
/**
|
|
16059
|
+
* Removes every membership of an account that is about to be deleted or anonymised: in every
|
|
16060
|
+
* membership status and every workspace, with one `member.removed` event per removal and the
|
|
16061
|
+
* cached access of each dropped.
|
|
16062
|
+
*
|
|
16063
|
+
* Refuses while the account is the only owner of an active or suspended workspace, so the host can
|
|
16064
|
+
* transfer ownership or schedule deletion first. A workspace pending deletion does not block:
|
|
16065
|
+
* no one can finalize it early, so the owner's membership there is removed too, the workspace can
|
|
16066
|
+
* no longer be restored, and the host's finalize job deletes it when its grace period ends.
|
|
16067
|
+
*
|
|
16068
|
+
* @param tenantId - The account's tenant.
|
|
16069
|
+
* @param userId - The account.
|
|
16070
|
+
* @param actorUserId - Who authorizes the deletion: the account, an administrator, or `null` for a
|
|
16071
|
+
* job. No workspace role does, so none is checked.
|
|
16072
|
+
* @param context - Request metadata for the hook.
|
|
16073
|
+
* @returns The memberships removed.
|
|
16074
|
+
* @throws {AuthException} `auth.last_owner`, with `details.workspaces`, while a workspace would be
|
|
16075
|
+
* left without an owner; nothing is removed.
|
|
16076
|
+
* @throws {MembershipBumpFailedError} When the removal committed but a cache bump failed.
|
|
16077
|
+
*/
|
|
16078
|
+
async removeAllForUser(tenantId, userId, actorUserId, context) {
|
|
16079
|
+
const blocking = await this.soleOwnedBlocking(tenantId, userId);
|
|
16080
|
+
if (blocking.length > 0) throw new AuthException(AUTH_ERROR_CODES.LAST_OWNER, {
|
|
16081
|
+
workspaces: blocking
|
|
16082
|
+
});
|
|
16083
|
+
const at = now();
|
|
16084
|
+
const outcome = await this.memberships.removeAllForUser({
|
|
16085
|
+
tenantId,
|
|
16086
|
+
userId,
|
|
16087
|
+
ownerRole: this.group.roles.ownerRole,
|
|
16088
|
+
audit: {
|
|
16089
|
+
type: "member.removed",
|
|
16090
|
+
tenantId,
|
|
16091
|
+
actorUserId,
|
|
16092
|
+
userId,
|
|
16093
|
+
at
|
|
16094
|
+
}
|
|
16095
|
+
});
|
|
16096
|
+
if (outcome.result === "last_owner") {
|
|
16097
|
+
throw new AuthException(AUTH_ERROR_CODES.LAST_OWNER, {
|
|
16098
|
+
workspaces: outcome.workspaceIds.map((id) => ({
|
|
16099
|
+
id
|
|
16100
|
+
}))
|
|
16101
|
+
});
|
|
16102
|
+
}
|
|
16103
|
+
const failed = [];
|
|
16104
|
+
let cause;
|
|
16105
|
+
for (const removed of outcome.removed) {
|
|
16106
|
+
this.events.emit({
|
|
16107
|
+
type: "member.removed",
|
|
16108
|
+
tenantId,
|
|
16109
|
+
workspaceId: removed.workspaceId,
|
|
16110
|
+
actorUserId,
|
|
16111
|
+
userId,
|
|
16112
|
+
at
|
|
16113
|
+
}, context);
|
|
16114
|
+
try {
|
|
16115
|
+
await this.access.invalidateMembership({
|
|
16116
|
+
tenantId,
|
|
16117
|
+
workspaceId: removed.workspaceId,
|
|
16118
|
+
userId
|
|
16119
|
+
});
|
|
16120
|
+
} catch (error) {
|
|
16121
|
+
if (failed.length === 0) cause = error;
|
|
16122
|
+
failed.push(removed);
|
|
16123
|
+
}
|
|
16124
|
+
}
|
|
16125
|
+
if (failed.length > 0) throw new MembershipBumpFailedError(outcome.removed, failed, cause);
|
|
16126
|
+
return outcome.removed;
|
|
16127
|
+
}
|
|
16128
|
+
/**
|
|
16042
16129
|
* Changes a member's role.
|
|
16043
16130
|
*
|
|
16044
16131
|
* @param ref - The workspace.
|
|
@@ -16295,6 +16382,35 @@ var MembershipService = class {
|
|
|
16295
16382
|
const { hierarchy, ownerRole } = this.group.roles;
|
|
16296
16383
|
return actorRole === ownerRole || actorRole !== otherRole && hasRole(actorRole, otherRole, hierarchy);
|
|
16297
16384
|
}
|
|
16385
|
+
/**
|
|
16386
|
+
* The workspaces that stop an account deletion: those the account alone owns, except the ones
|
|
16387
|
+
* pending deletion or deleted. Stops reading pages once a full page of them is known.
|
|
16388
|
+
*/
|
|
16389
|
+
async soleOwnedBlocking(tenantId, userId) {
|
|
16390
|
+
const blocking = [];
|
|
16391
|
+
let cursor;
|
|
16392
|
+
do {
|
|
16393
|
+
const page = await this.memberships.listSoleOwned({
|
|
16394
|
+
tenantId,
|
|
16395
|
+
userId,
|
|
16396
|
+
ownerRole: this.group.roles.ownerRole,
|
|
16397
|
+
...cursor === void 0 ? {} : {
|
|
16398
|
+
cursor
|
|
16399
|
+
},
|
|
16400
|
+
limit: MAX_PAGE_SIZE
|
|
16401
|
+
});
|
|
16402
|
+
for (const workspace of page.items) {
|
|
16403
|
+
if (workspace.status === "pending_deletion" || workspace.status === "deleted") continue;
|
|
16404
|
+
blocking.push({
|
|
16405
|
+
id: workspace.id,
|
|
16406
|
+
name: workspace.name,
|
|
16407
|
+
status: workspace.status
|
|
16408
|
+
});
|
|
16409
|
+
}
|
|
16410
|
+
cursor = page.nextCursor ?? void 0;
|
|
16411
|
+
} while (cursor !== void 0 && blocking.length < MAX_PAGE_SIZE);
|
|
16412
|
+
return blocking.slice(0, MAX_PAGE_SIZE);
|
|
16413
|
+
}
|
|
16298
16414
|
async removeWith(ref, userId, event, context, judged2) {
|
|
16299
16415
|
const result = await this.memberships.remove({
|
|
16300
16416
|
...ref,
|
|
@@ -24990,4 +25106,4 @@ function stampJobContext(workspace) {
|
|
|
24990
25106
|
}
|
|
24991
25107
|
__name(stampJobContext, "stampJobContext");
|
|
24992
25108
|
|
|
24993
|
-
export { ALLOW_PENDING_WORKSPACE_KEY, ANY_WORKSPACE_MEMBER, API_KEY_MAX_LABEL_LENGTH, API_KEY_MAX_OVERLAP_SECONDS, AUTH_EMAIL_KINDS, AUTH_ERROR_CODES, AUTH_ERROR_MESSAGES, AUTH_ERROR_STATUS, AUTH_SECURITY_SCHEMES, AUTH_THROTTLE_CONFIGS, AcceptInvitationDto, AccountStatusService, AllowAllBreachChecker, AllowPendingWorkspace, ApiKeyGuard, ApiKeyScopes, ApiKeyService, AuthException, AuthExceptionFilter, AuthRateLimit, AuthRateLimitGuard, AuthRevocationService, AuthService, AuthTokenVerifierService, Authenticated, BYMAX_AUTH_API_KEY_CLOCK, BYMAX_AUTH_API_KEY_REPOSITORY, BYMAX_AUTH_BREACH_CHECKER, BYMAX_AUTH_EMAIL_PROVIDER, BYMAX_AUTH_HOOKS, BYMAX_AUTH_MEMBERSHIP_REPOSITORY, BYMAX_AUTH_OPTIONS, BYMAX_AUTH_PLATFORM_USER_REPOSITORY, BYMAX_AUTH_REDIS_CLIENT, BYMAX_AUTH_USER_REPOSITORY, BYMAX_AUTH_WORKSPACE_REPOSITORY, BruteForceService, BymaxAuthModule, ChangePasswordDto, CommonPasswordChecker, CreateInvitationDto, CurrentApiKey, CurrentUser, CurrentWorkspace, CurrentWsWorkspace, DefaultAuthEmailProvider, EmailChangeService, ForgotPasswordDto, HibpBreachChecker, IS_PUBLIC_KEY, InvitationService, JwtAuthGuard, JwtPlatformGuard, LoginDto, MembershipService, MfaChallengeDto, MfaDisableDto, MfaRegenerateRecoveryCodesDto, MfaRequiredGuard, MfaService, MfaVerifyDto, NoOpAuthHooks, NoOpEmailProvider, OAuthService, OptionalAuthGuard, OtpService, PLATFORM_ROLES_KEY, PasswordResetService, PlatformAuthService, PlatformLoginDto, PlatformRoles, PlatformRolesGuard, Public, ROLES_KEY, ReauthenticationService, RegisterDto, RequestEncoding, RequestEncodingGuard, ResendOtpDto, ResendVerificationDto, ResetPasswordDto, Roles, RolesGuard, SKIP_MFA_KEY, SelfOrAdminGuard, ServiceKey, SessionService, SkipMfa, TokenDeliveryService, TrustedOriginGuard, UserStatusGuard, VerifyEmailDto, VerifyOtpDto, WORKSPACE_PERMISSION_KEY, WORKSPACE_ROLES_KEY, WS_TICKET_TTL_SECONDS, WorkspaceAccessService, WorkspaceActionsService, WorkspaceCallerService, WorkspaceGuard, WorkspaceInvitationService, WorkspacePermission, WorkspaceRoles, WorkspaceService, WsAuthExceptionFilter, WsJwtGuard, WsTicketService, WsWorkspaceGuard, authDocumentSecurity, createAuthValidationPipe, decodeWorkspaceScopedName, decrypt, describeChannelStatus, describeError, encrypt, generateSecureToken, hasRole, hmacSha256, redactSecrets, reduceToBaseWord, sanitizeHeaders, sha256, sleep, stampJobContext, timingSafeCompare, workspaceScopedName };
|
|
25109
|
+
export { ALLOW_PENDING_WORKSPACE_KEY, ANY_WORKSPACE_MEMBER, API_KEY_MAX_LABEL_LENGTH, API_KEY_MAX_OVERLAP_SECONDS, AUTH_EMAIL_KINDS, AUTH_ERROR_CODES, AUTH_ERROR_MESSAGES, AUTH_ERROR_STATUS, AUTH_SECURITY_SCHEMES, AUTH_THROTTLE_CONFIGS, AcceptInvitationDto, AccountStatusService, AllowAllBreachChecker, AllowPendingWorkspace, ApiKeyGuard, ApiKeyScopes, ApiKeyService, AuthException, AuthExceptionFilter, AuthRateLimit, AuthRateLimitGuard, AuthRevocationService, AuthService, AuthTokenVerifierService, Authenticated, BYMAX_AUTH_API_KEY_CLOCK, BYMAX_AUTH_API_KEY_REPOSITORY, BYMAX_AUTH_BREACH_CHECKER, BYMAX_AUTH_EMAIL_PROVIDER, BYMAX_AUTH_HOOKS, BYMAX_AUTH_MEMBERSHIP_REPOSITORY, BYMAX_AUTH_OPTIONS, BYMAX_AUTH_PLATFORM_USER_REPOSITORY, BYMAX_AUTH_REDIS_CLIENT, BYMAX_AUTH_USER_REPOSITORY, BYMAX_AUTH_WORKSPACE_REPOSITORY, BruteForceService, BymaxAuthModule, ChangePasswordDto, CommonPasswordChecker, CreateInvitationDto, CurrentApiKey, CurrentUser, CurrentWorkspace, CurrentWsWorkspace, DefaultAuthEmailProvider, EmailChangeService, ForgotPasswordDto, HibpBreachChecker, IS_PUBLIC_KEY, InvitationService, JwtAuthGuard, JwtPlatformGuard, LoginDto, MembershipBumpFailedError, MembershipService, MfaChallengeDto, MfaDisableDto, MfaRegenerateRecoveryCodesDto, MfaRequiredGuard, MfaService, MfaVerifyDto, NoOpAuthHooks, NoOpEmailProvider, OAuthService, OptionalAuthGuard, OtpService, PLATFORM_ROLES_KEY, PasswordResetService, PlatformAuthService, PlatformLoginDto, PlatformRoles, PlatformRolesGuard, Public, ROLES_KEY, ReauthenticationService, RegisterDto, RequestEncoding, RequestEncodingGuard, ResendOtpDto, ResendVerificationDto, ResetPasswordDto, Roles, RolesGuard, SKIP_MFA_KEY, SelfOrAdminGuard, ServiceKey, SessionService, SkipMfa, TokenDeliveryService, TrustedOriginGuard, UserStatusGuard, VerifyEmailDto, VerifyOtpDto, WORKSPACE_PERMISSION_KEY, WORKSPACE_ROLES_KEY, WS_TICKET_TTL_SECONDS, WorkspaceAccessService, WorkspaceActionsService, WorkspaceCallerService, WorkspaceGuard, WorkspaceInvitationService, WorkspacePermission, WorkspaceRoles, WorkspaceService, WsAuthExceptionFilter, WsJwtGuard, WsTicketService, WsWorkspaceGuard, authDocumentSecurity, createAuthValidationPipe, decodeWorkspaceScopedName, decrypt, describeChannelStatus, describeError, encrypt, generateSecureToken, hasRole, hmacSha256, redactSecrets, reduceToBaseWord, sanitizeHeaders, sha256, sleep, stampJobContext, timingSafeCompare, workspaceScopedName };
|
package/dist/shared/index.cjs
CHANGED
|
@@ -456,6 +456,7 @@ exports.AUTH_REFRESH_COOKIE_PATH = AUTH_REFRESH_COOKIE_PATH;
|
|
|
456
456
|
exports.AUTH_REFRESH_SKIP_PATH_SUFFIXES = AUTH_REFRESH_SKIP_PATH_SUFFIXES;
|
|
457
457
|
exports.AUTH_ROUTES = AUTH_ROUTES;
|
|
458
458
|
exports.AUTH_SESSION_ROUTES = AUTH_SESSION_ROUTES;
|
|
459
|
+
exports.AUTH_WORKSPACE_ROUTES = AUTH_WORKSPACE_ROUTES;
|
|
459
460
|
exports.AuthClientError = AuthClientError;
|
|
460
461
|
exports.buildAuthRefreshSkipSuffixes = buildAuthRefreshSkipSuffixes;
|
|
461
462
|
exports.fillRoute = fillRoute;
|
package/dist/shared/index.d.cts
CHANGED
|
@@ -405,6 +405,60 @@ declare const AUTH_OAUTH_ROUTES: {
|
|
|
405
405
|
/** GET — the provider redirects back here with the authorization code. */
|
|
406
406
|
readonly callback: "oauth/:provider/callback";
|
|
407
407
|
};
|
|
408
|
+
/**
|
|
409
|
+
* Workspace routes (`controllers.workspaces: true`).
|
|
410
|
+
*
|
|
411
|
+
* Mounted under `workspaces/` (`src/server/controllers/workspace.controller.ts`). The
|
|
412
|
+
* `:workspaceId` placeholder must be substituted before the request is issued; the workspace a
|
|
413
|
+
* request acts in is always this path segment, never the body or a header.
|
|
414
|
+
*/
|
|
415
|
+
declare const AUTH_WORKSPACE_ROUTES: {
|
|
416
|
+
/**
|
|
417
|
+
* GET — the caller's own active memberships and the workspace they last switched to. POST on the
|
|
418
|
+
* same path creates a workspace.
|
|
419
|
+
*/
|
|
420
|
+
readonly list: "workspaces";
|
|
421
|
+
/** GET — the workspace and the caller's role in it. */
|
|
422
|
+
readonly access: "workspaces/:workspaceId/access";
|
|
423
|
+
/** POST — record the workspace as the caller's last active one. */
|
|
424
|
+
readonly switch: "workspaces/:workspaceId/switch";
|
|
425
|
+
/** GET — the members of the workspace. */
|
|
426
|
+
readonly members: "workspaces/:workspaceId/members";
|
|
427
|
+
/** PATCH — rename the workspace. */
|
|
428
|
+
readonly rename: "workspaces/:workspaceId";
|
|
429
|
+
/**
|
|
430
|
+
* POST — schedule the workspace for deletion, re-proving the caller.
|
|
431
|
+
*
|
|
432
|
+
* POST rather than DELETE because the password travels in the body, and a payload on DELETE has
|
|
433
|
+
* no defined semantics (RFC 9110), so an intermediary or a generated client may drop it.
|
|
434
|
+
*/
|
|
435
|
+
readonly scheduleDeletion: "workspaces/:workspaceId/schedule-deletion";
|
|
436
|
+
/** POST — undo a scheduled deletion within its grace period. */
|
|
437
|
+
readonly restore: "workspaces/:workspaceId/restore";
|
|
438
|
+
/**
|
|
439
|
+
* PATCH — change a member's role. DELETE on the same path removes the member, with no body.
|
|
440
|
+
*/
|
|
441
|
+
readonly member: "workspaces/:workspaceId/members/:userId";
|
|
442
|
+
/** POST — leave the workspace. */
|
|
443
|
+
readonly leave: "workspaces/:workspaceId/leave";
|
|
444
|
+
/** POST — hand ownership to another member, re-proving the caller. */
|
|
445
|
+
readonly transferOwnership: "workspaces/:workspaceId/transfer-ownership";
|
|
446
|
+
/**
|
|
447
|
+
* POST — invite an address to the workspace (`controllers.workspaceInvitations: true`). GET on the
|
|
448
|
+
* same path lists the pending invitations.
|
|
449
|
+
*/
|
|
450
|
+
readonly invitations: "workspaces/:workspaceId/invitations";
|
|
451
|
+
/** POST — send a pending invitation again under a new token. */
|
|
452
|
+
readonly resendInvitation: "workspaces/:workspaceId/invitations/resend";
|
|
453
|
+
/** POST — withdraw a pending invitation. */
|
|
454
|
+
readonly revokeInvitation: "workspaces/:workspaceId/invitations/revoke";
|
|
455
|
+
/** POST — what a token is for, without signing in. Public. */
|
|
456
|
+
readonly previewInvitation: "workspaces/invitations/preview";
|
|
457
|
+
/** POST — accept an invitation as the signed-in account it was addressed to. */
|
|
458
|
+
readonly acceptInvitation: "workspaces/invitations/accept";
|
|
459
|
+
/** POST — accept an invitation by creating the account it was addressed to. Public. */
|
|
460
|
+
readonly acceptInvitationSignup: "workspaces/invitations/accept-signup";
|
|
461
|
+
};
|
|
408
462
|
/**
|
|
409
463
|
* Aggregated route map grouped by domain.
|
|
410
464
|
*
|
|
@@ -1170,5 +1224,5 @@ type AuthContextKind = 'dashboard' | 'platform';
|
|
|
1170
1224
|
*/
|
|
1171
1225
|
type TokenDeliveryMode = 'cookie' | 'bearer';
|
|
1172
1226
|
|
|
1173
|
-
export { AUTH_ACCESS_COOKIE_NAME, AUTH_DASHBOARD_ROUTES, AUTH_EMAIL_CHANGE_ROUTES, AUTH_ERROR_CODES, AUTH_ERROR_STATUS, AUTH_HAS_SESSION_COOKIE_NAME, AUTH_INVITATION_ROUTES, AUTH_MFA_ROUTES, AUTH_OAUTH_ROUTES, AUTH_PASSWORD_ROUTES, AUTH_PLATFORM_MFA_ROUTES, AUTH_PLATFORM_ROUTES, AUTH_PROXY_ROUTES, AUTH_REFRESH_COOKIE_NAME, AUTH_REFRESH_COOKIE_PATH, AUTH_REFRESH_SKIP_PATH_SUFFIXES, AUTH_ROUTES, AUTH_SESSION_ROUTES, AuthClientError, buildAuthRefreshSkipSuffixes, fillRoute, pathSegment, trimSlashes };
|
|
1227
|
+
export { AUTH_ACCESS_COOKIE_NAME, AUTH_DASHBOARD_ROUTES, AUTH_EMAIL_CHANGE_ROUTES, AUTH_ERROR_CODES, AUTH_ERROR_STATUS, AUTH_HAS_SESSION_COOKIE_NAME, AUTH_INVITATION_ROUTES, AUTH_MFA_ROUTES, AUTH_OAUTH_ROUTES, AUTH_PASSWORD_ROUTES, AUTH_PLATFORM_MFA_ROUTES, AUTH_PLATFORM_ROUTES, AUTH_PROXY_ROUTES, AUTH_REFRESH_COOKIE_NAME, AUTH_REFRESH_COOKIE_PATH, AUTH_REFRESH_SKIP_PATH_SUFFIXES, AUTH_ROUTES, AUTH_SESSION_ROUTES, AUTH_WORKSPACE_ROUTES, AuthClientError, buildAuthRefreshSkipSuffixes, fillRoute, pathSegment, trimSlashes };
|
|
1174
1228
|
export type { AcceptedWorkspaceInvitation, AuthContextKind, AuthCookieNames, AuthErrorCode, AuthErrorResponse, AuthJwtPayload, AuthPlatformUserClient, AuthResponseCode, AuthResult, AuthUserClient, BootstrapInvitationPreviewClient, DashboardJwtPayload, LoginResult, MemberInvitationPreviewClient, MembershipStatusClient, MfaChallengeResult, MfaTempPayload, PlatformAuthResult, PlatformJwtPayload, PlatformLoginResult, TokenDeliveryMode, WorkspaceAccessClient, WorkspaceClient, WorkspaceInvitationClient, WorkspaceInvitationPage, WorkspaceInvitationPreview, WorkspaceListResult, WorkspaceMemberClient, WorkspaceMemberPage, WorkspacePageParams, WorkspaceStatusClient };
|
package/dist/shared/index.d.ts
CHANGED
|
@@ -405,6 +405,60 @@ declare const AUTH_OAUTH_ROUTES: {
|
|
|
405
405
|
/** GET — the provider redirects back here with the authorization code. */
|
|
406
406
|
readonly callback: "oauth/:provider/callback";
|
|
407
407
|
};
|
|
408
|
+
/**
|
|
409
|
+
* Workspace routes (`controllers.workspaces: true`).
|
|
410
|
+
*
|
|
411
|
+
* Mounted under `workspaces/` (`src/server/controllers/workspace.controller.ts`). The
|
|
412
|
+
* `:workspaceId` placeholder must be substituted before the request is issued; the workspace a
|
|
413
|
+
* request acts in is always this path segment, never the body or a header.
|
|
414
|
+
*/
|
|
415
|
+
declare const AUTH_WORKSPACE_ROUTES: {
|
|
416
|
+
/**
|
|
417
|
+
* GET — the caller's own active memberships and the workspace they last switched to. POST on the
|
|
418
|
+
* same path creates a workspace.
|
|
419
|
+
*/
|
|
420
|
+
readonly list: "workspaces";
|
|
421
|
+
/** GET — the workspace and the caller's role in it. */
|
|
422
|
+
readonly access: "workspaces/:workspaceId/access";
|
|
423
|
+
/** POST — record the workspace as the caller's last active one. */
|
|
424
|
+
readonly switch: "workspaces/:workspaceId/switch";
|
|
425
|
+
/** GET — the members of the workspace. */
|
|
426
|
+
readonly members: "workspaces/:workspaceId/members";
|
|
427
|
+
/** PATCH — rename the workspace. */
|
|
428
|
+
readonly rename: "workspaces/:workspaceId";
|
|
429
|
+
/**
|
|
430
|
+
* POST — schedule the workspace for deletion, re-proving the caller.
|
|
431
|
+
*
|
|
432
|
+
* POST rather than DELETE because the password travels in the body, and a payload on DELETE has
|
|
433
|
+
* no defined semantics (RFC 9110), so an intermediary or a generated client may drop it.
|
|
434
|
+
*/
|
|
435
|
+
readonly scheduleDeletion: "workspaces/:workspaceId/schedule-deletion";
|
|
436
|
+
/** POST — undo a scheduled deletion within its grace period. */
|
|
437
|
+
readonly restore: "workspaces/:workspaceId/restore";
|
|
438
|
+
/**
|
|
439
|
+
* PATCH — change a member's role. DELETE on the same path removes the member, with no body.
|
|
440
|
+
*/
|
|
441
|
+
readonly member: "workspaces/:workspaceId/members/:userId";
|
|
442
|
+
/** POST — leave the workspace. */
|
|
443
|
+
readonly leave: "workspaces/:workspaceId/leave";
|
|
444
|
+
/** POST — hand ownership to another member, re-proving the caller. */
|
|
445
|
+
readonly transferOwnership: "workspaces/:workspaceId/transfer-ownership";
|
|
446
|
+
/**
|
|
447
|
+
* POST — invite an address to the workspace (`controllers.workspaceInvitations: true`). GET on the
|
|
448
|
+
* same path lists the pending invitations.
|
|
449
|
+
*/
|
|
450
|
+
readonly invitations: "workspaces/:workspaceId/invitations";
|
|
451
|
+
/** POST — send a pending invitation again under a new token. */
|
|
452
|
+
readonly resendInvitation: "workspaces/:workspaceId/invitations/resend";
|
|
453
|
+
/** POST — withdraw a pending invitation. */
|
|
454
|
+
readonly revokeInvitation: "workspaces/:workspaceId/invitations/revoke";
|
|
455
|
+
/** POST — what a token is for, without signing in. Public. */
|
|
456
|
+
readonly previewInvitation: "workspaces/invitations/preview";
|
|
457
|
+
/** POST — accept an invitation as the signed-in account it was addressed to. */
|
|
458
|
+
readonly acceptInvitation: "workspaces/invitations/accept";
|
|
459
|
+
/** POST — accept an invitation by creating the account it was addressed to. Public. */
|
|
460
|
+
readonly acceptInvitationSignup: "workspaces/invitations/accept-signup";
|
|
461
|
+
};
|
|
408
462
|
/**
|
|
409
463
|
* Aggregated route map grouped by domain.
|
|
410
464
|
*
|
|
@@ -1170,5 +1224,5 @@ type AuthContextKind = 'dashboard' | 'platform';
|
|
|
1170
1224
|
*/
|
|
1171
1225
|
type TokenDeliveryMode = 'cookie' | 'bearer';
|
|
1172
1226
|
|
|
1173
|
-
export { AUTH_ACCESS_COOKIE_NAME, AUTH_DASHBOARD_ROUTES, AUTH_EMAIL_CHANGE_ROUTES, AUTH_ERROR_CODES, AUTH_ERROR_STATUS, AUTH_HAS_SESSION_COOKIE_NAME, AUTH_INVITATION_ROUTES, AUTH_MFA_ROUTES, AUTH_OAUTH_ROUTES, AUTH_PASSWORD_ROUTES, AUTH_PLATFORM_MFA_ROUTES, AUTH_PLATFORM_ROUTES, AUTH_PROXY_ROUTES, AUTH_REFRESH_COOKIE_NAME, AUTH_REFRESH_COOKIE_PATH, AUTH_REFRESH_SKIP_PATH_SUFFIXES, AUTH_ROUTES, AUTH_SESSION_ROUTES, AuthClientError, buildAuthRefreshSkipSuffixes, fillRoute, pathSegment, trimSlashes };
|
|
1227
|
+
export { AUTH_ACCESS_COOKIE_NAME, AUTH_DASHBOARD_ROUTES, AUTH_EMAIL_CHANGE_ROUTES, AUTH_ERROR_CODES, AUTH_ERROR_STATUS, AUTH_HAS_SESSION_COOKIE_NAME, AUTH_INVITATION_ROUTES, AUTH_MFA_ROUTES, AUTH_OAUTH_ROUTES, AUTH_PASSWORD_ROUTES, AUTH_PLATFORM_MFA_ROUTES, AUTH_PLATFORM_ROUTES, AUTH_PROXY_ROUTES, AUTH_REFRESH_COOKIE_NAME, AUTH_REFRESH_COOKIE_PATH, AUTH_REFRESH_SKIP_PATH_SUFFIXES, AUTH_ROUTES, AUTH_SESSION_ROUTES, AUTH_WORKSPACE_ROUTES, AuthClientError, buildAuthRefreshSkipSuffixes, fillRoute, pathSegment, trimSlashes };
|
|
1174
1228
|
export type { AcceptedWorkspaceInvitation, AuthContextKind, AuthCookieNames, AuthErrorCode, AuthErrorResponse, AuthJwtPayload, AuthPlatformUserClient, AuthResponseCode, AuthResult, AuthUserClient, BootstrapInvitationPreviewClient, DashboardJwtPayload, LoginResult, MemberInvitationPreviewClient, MembershipStatusClient, MfaChallengeResult, MfaTempPayload, PlatformAuthResult, PlatformJwtPayload, PlatformLoginResult, TokenDeliveryMode, WorkspaceAccessClient, WorkspaceClient, WorkspaceInvitationClient, WorkspaceInvitationPage, WorkspaceInvitationPreview, WorkspaceListResult, WorkspaceMemberClient, WorkspaceMemberPage, WorkspacePageParams, WorkspaceStatusClient };
|
package/dist/shared/index.mjs
CHANGED
|
@@ -436,4 +436,4 @@ var AuthClientError = class extends Error {
|
|
|
436
436
|
}
|
|
437
437
|
};
|
|
438
438
|
|
|
439
|
-
export { AUTH_ACCESS_COOKIE_NAME, AUTH_DASHBOARD_ROUTES, AUTH_EMAIL_CHANGE_ROUTES, AUTH_ERROR_CODES, AUTH_ERROR_STATUS, AUTH_HAS_SESSION_COOKIE_NAME, AUTH_INVITATION_ROUTES, AUTH_MFA_ROUTES, AUTH_OAUTH_ROUTES, AUTH_PASSWORD_ROUTES, AUTH_PLATFORM_MFA_ROUTES, AUTH_PLATFORM_ROUTES, AUTH_PROXY_ROUTES, AUTH_REFRESH_COOKIE_NAME, AUTH_REFRESH_COOKIE_PATH, AUTH_REFRESH_SKIP_PATH_SUFFIXES, AUTH_ROUTES, AUTH_SESSION_ROUTES, AuthClientError, buildAuthRefreshSkipSuffixes, fillRoute, pathSegment, trimSlashes };
|
|
439
|
+
export { AUTH_ACCESS_COOKIE_NAME, AUTH_DASHBOARD_ROUTES, AUTH_EMAIL_CHANGE_ROUTES, AUTH_ERROR_CODES, AUTH_ERROR_STATUS, AUTH_HAS_SESSION_COOKIE_NAME, AUTH_INVITATION_ROUTES, AUTH_MFA_ROUTES, AUTH_OAUTH_ROUTES, AUTH_PASSWORD_ROUTES, AUTH_PLATFORM_MFA_ROUTES, AUTH_PLATFORM_ROUTES, AUTH_PROXY_ROUTES, AUTH_REFRESH_COOKIE_NAME, AUTH_REFRESH_COOKIE_PATH, AUTH_REFRESH_SKIP_PATH_SUFFIXES, AUTH_ROUTES, AUTH_SESSION_ROUTES, AUTH_WORKSPACE_ROUTES, AuthClientError, buildAuthRefreshSkipSuffixes, fillRoute, pathSegment, trimSlashes };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bymax-one/nest-auth",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.1",
|
|
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",
|