@bymax-one/nest-auth 1.5.0 → 1.5.2
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 +123 -1
- package/README.md +49 -7
- 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 +225 -27
- package/dist/server/index.d.cts +127 -12
- package/dist/server/index.d.ts +127 -12
- package/dist/server/index.mjs +225 -28
- 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/dist/server/index.d.ts
CHANGED
|
@@ -707,8 +707,9 @@ declare const ANY_WORKSPACE_MEMBER: unique symbol;
|
|
|
707
707
|
* address. `POST /auth/register` and the OAuth `create` action answer `403
|
|
708
708
|
* auth.registration_closed`, the invitation accept routes stay open, and an OAuth flow started
|
|
709
709
|
* with a workspace invitation may create the account it was addressed to. Existing accounts
|
|
710
|
-
* keep signing in. Startup refuses the mode
|
|
711
|
-
*
|
|
710
|
+
* keep signing in. Startup refuses the mode unless an invitation controller is mounted
|
|
711
|
+
* (`controllers.workspaceInvitations` with `workspaces.enabled`, or `controllers.invitations`
|
|
712
|
+
* with `invitations.enabled`), since otherwise no account could ever be created.
|
|
712
713
|
*/
|
|
713
714
|
type RegistrationMode = 'open' | 'invitation-only';
|
|
714
715
|
/** A role list in which `ANY_WORKSPACE_MEMBER` stands for every active member. */
|
|
@@ -3001,6 +3002,12 @@ interface WorkspaceInviteData {
|
|
|
3001
3002
|
expiresAt: Date;
|
|
3002
3003
|
/** Whether an account already exists for the address: sign-in wording versus sign-up wording. */
|
|
3003
3004
|
accountExists: boolean;
|
|
3005
|
+
/**
|
|
3006
|
+
* `'member'` joins a workspace that exists; `'bootstrap'` is a platform invitation to own a
|
|
3007
|
+
* workspace that is created when the invitee accepts, so `workspaceName` names one that does not
|
|
3008
|
+
* exist yet and `inviterName` is a display name the platform chose, which may be empty.
|
|
3009
|
+
*/
|
|
3010
|
+
kind: 'member' | 'bootstrap';
|
|
3004
3011
|
}
|
|
3005
3012
|
/**
|
|
3006
3013
|
* Data required to render and send a tenant invitation email.
|
|
@@ -4948,6 +4955,48 @@ type GuardedWriteResult = 'ok' | 'not_found' | 'last_owner';
|
|
|
4948
4955
|
type MemberChangeResult = GuardedWriteResult | 'actor_changed';
|
|
4949
4956
|
/** Outcome of {@link IMembershipRepository.transferOwnership}. */
|
|
4950
4957
|
type TransferOwnershipResult = GuardedWriteResult | 'target_not_member';
|
|
4958
|
+
/**
|
|
4959
|
+
* The event persisted for each membership {@link IMembershipRepository.removeAllForUser} deletes.
|
|
4960
|
+
* The repository stores one `member.removed` event per removed membership, naming that
|
|
4961
|
+
* membership's workspace, and nothing else is added to it.
|
|
4962
|
+
*/
|
|
4963
|
+
interface AccountRemovalAudit {
|
|
4964
|
+
type: 'member.removed';
|
|
4965
|
+
/** The tenant of the account. */
|
|
4966
|
+
tenantId: string;
|
|
4967
|
+
/** Who authorized the removal: the member themselves, an administrator, or `null` for a job. */
|
|
4968
|
+
actorUserId: string | null;
|
|
4969
|
+
/** The account whose memberships are removed. */
|
|
4970
|
+
userId: string;
|
|
4971
|
+
/** When the removal was decided, as an ISO-8601 string. */
|
|
4972
|
+
at: string;
|
|
4973
|
+
}
|
|
4974
|
+
/** Input to {@link IMembershipRepository.removeAllForUser}. */
|
|
4975
|
+
interface RemoveAllMembershipsParams {
|
|
4976
|
+
/** The tenant of the account. */
|
|
4977
|
+
tenantId: string;
|
|
4978
|
+
/** The account whose memberships are removed. */
|
|
4979
|
+
userId: string;
|
|
4980
|
+
/** The role that owns a workspace, so the last-owner rule can be decided with the write. */
|
|
4981
|
+
ownerRole: string;
|
|
4982
|
+
/** The event to persist for each membership removed. */
|
|
4983
|
+
audit: AccountRemovalAudit;
|
|
4984
|
+
}
|
|
4985
|
+
/** One membership an account removal deleted. */
|
|
4986
|
+
interface RemovedMembership {
|
|
4987
|
+
/** The workspace the membership was in. */
|
|
4988
|
+
workspaceId: string;
|
|
4989
|
+
/** The role the account held there. */
|
|
4990
|
+
role: string;
|
|
4991
|
+
}
|
|
4992
|
+
/** Outcome of {@link IMembershipRepository.removeAllForUser}. */
|
|
4993
|
+
type RemoveAllMembershipsResult = {
|
|
4994
|
+
result: 'ok';
|
|
4995
|
+
removed: RemovedMembership[];
|
|
4996
|
+
} | {
|
|
4997
|
+
result: 'last_owner';
|
|
4998
|
+
workspaceIds: string[];
|
|
4999
|
+
};
|
|
4951
5000
|
/**
|
|
4952
5001
|
* The membership port a host implements.
|
|
4953
5002
|
*
|
|
@@ -5047,6 +5096,24 @@ interface IMembershipRepository {
|
|
|
5047
5096
|
* @param params - The membership key, the roles judged, owner role and audit event.
|
|
5048
5097
|
*/
|
|
5049
5098
|
remove(params: RemoveMembershipParams): Promise<MemberChangeResult>;
|
|
5099
|
+
/**
|
|
5100
|
+
* Removes every membership of an account, in every membership status and in every workspace
|
|
5101
|
+
* status, persisting one `audit` event per removed membership in the same transaction.
|
|
5102
|
+
*
|
|
5103
|
+
* For the host that is about to delete or anonymise a user. `listForUser` shows only active
|
|
5104
|
+
* memberships of active workspaces, so only the repository can find the rest.
|
|
5105
|
+
*
|
|
5106
|
+
* The last-owner rule is decided inside the transaction: when the account is the only active
|
|
5107
|
+
* `ownerRole` holder of a workspace that is not `pending_deletion` or `deleted`, nothing is
|
|
5108
|
+
* removed, no audit row is written and the answer names those workspaces. A workspace pending
|
|
5109
|
+
* deletion does not block: no one can finalize it early, and its owner must not wait out the
|
|
5110
|
+
* grace period to delete their account. Removing the owner's membership there means the
|
|
5111
|
+
* workspace can no longer be restored, and it is deleted when its grace period ends.
|
|
5112
|
+
*
|
|
5113
|
+
* @param params - The tenant, the account, the owner role and the event template.
|
|
5114
|
+
* @returns The removed memberships, or `'last_owner'` with the ids of the workspaces that block.
|
|
5115
|
+
*/
|
|
5116
|
+
removeAllForUser(params: RemoveAllMembershipsParams): Promise<RemoveAllMembershipsResult>;
|
|
5050
5117
|
/**
|
|
5051
5118
|
* Hands ownership from one member to another in one transaction, persisting `audit` with it.
|
|
5052
5119
|
*
|
|
@@ -5319,6 +5386,10 @@ interface AuthEmailCatalogue {
|
|
|
5319
5386
|
invitation(input: AuthEmailContext & {
|
|
5320
5387
|
invite: InviteData;
|
|
5321
5388
|
}): AuthEmailMessage;
|
|
5389
|
+
/** Invitation to a workspace, or to set one up and own it. */
|
|
5390
|
+
workspaceInvitation(input: AuthEmailContext & {
|
|
5391
|
+
invite: WorkspaceInviteData;
|
|
5392
|
+
}): AuthEmailMessage;
|
|
5322
5393
|
}
|
|
5323
5394
|
/** How the provider reacts to a delivery failure. */
|
|
5324
5395
|
type DeliveryErrorPolicy = 'swallow' | 'rethrow';
|
|
@@ -5331,7 +5402,7 @@ type AuthEmailKind = keyof AuthEmailCatalogue;
|
|
|
5331
5402
|
* bare `'rethrow'` needs the list. Kept adjacent to {@link AuthEmailCatalogue} so the two are read
|
|
5332
5403
|
* together; a catalogue entry added without a matching entry here fails the test that compares them.
|
|
5333
5404
|
*/
|
|
5334
|
-
declare const AUTH_EMAIL_KINDS: readonly ["passwordResetToken", "passwordResetOtp", "emailVerificationOtp", "passwordChanged", "emailChangeVerification", "emailChanged", "mfaEnabled", "mfaDisabled", "newSessionAlert", "invitation"];
|
|
5405
|
+
declare const AUTH_EMAIL_KINDS: readonly ["passwordResetToken", "passwordResetOtp", "emailVerificationOtp", "passwordChanged", "emailChangeVerification", "emailChanged", "mfaEnabled", "mfaDisabled", "newSessionAlert", "invitation", "workspaceInvitation"];
|
|
5335
5406
|
/**
|
|
5336
5407
|
* A delivery-error policy chosen per message.
|
|
5337
5408
|
*
|
|
@@ -5371,9 +5442,9 @@ interface DefaultAuthEmailProviderOptions {
|
|
|
5371
5442
|
* that. `redactSecrets` is for strings you know contain the literal value. This is the one
|
|
5372
5443
|
* credential this library cannot contain on your behalf.
|
|
5373
5444
|
*
|
|
5374
|
-
* **Which is why this takes a MAP as well as a bare policy.**
|
|
5445
|
+
* **Which is why this takes a MAP as well as a bare policy.** Six messages carry a credential
|
|
5375
5446
|
* in their body, and the two flows that motivate the opt-in are two of them — so a bare
|
|
5376
|
-
* `'rethrow'` reaches
|
|
5447
|
+
* `'rethrow'` reaches four MORE credential-bearing paths than anyone asked for, on top of every
|
|
5377
5448
|
* message that carries none. Naming the flows keeps the unlaundered error where a deployment
|
|
5378
5449
|
* wanted it and leaves it off the rest:
|
|
5379
5450
|
*
|
|
@@ -5385,7 +5456,7 @@ interface DefaultAuthEmailProviderOptions {
|
|
|
5385
5456
|
*
|
|
5386
5457
|
* A message left out of the map keeps `'swallow'`, so the safe value is what you get by saying
|
|
5387
5458
|
* nothing, and widening the opt-in is always an explicit act. A bare policy still works and
|
|
5388
|
-
* still applies to
|
|
5459
|
+
* still applies to every message — it is the coarse form, kept because it is the honest way to say
|
|
5389
5460
|
* "this deployment wants the throw everywhere".
|
|
5390
5461
|
*/
|
|
5391
5462
|
readonly onDeliveryError?: DeliveryErrorPolicy | DeliveryErrorPolicyMap;
|
|
@@ -5408,7 +5479,7 @@ interface DefaultAuthEmailProviderOptions {
|
|
|
5408
5479
|
* a channel that is down would turn each into a failed request over a message that is a
|
|
5409
5480
|
* notification rather than the operation itself. The failure is logged and the flow continues.
|
|
5410
5481
|
* Setting `'rethrow'` makes EVERY method reject with the channel's original error — there is one
|
|
5411
|
-
* `deliver()` behind all
|
|
5482
|
+
* `deliver()` behind all of them and one place the policy is read, so no method is exempt. That is the
|
|
5412
5483
|
* whole point of the option and is documented with the duty it carries.
|
|
5413
5484
|
*
|
|
5414
5485
|
* The three MFA notices are the exception at the CALLER rather than here: `MfaService` sends them
|
|
@@ -5424,8 +5495,8 @@ interface DefaultAuthEmailProviderOptions {
|
|
|
5424
5495
|
* verification the recipient never got, so it cannot complete. A deployment that wants the throw
|
|
5425
5496
|
* back on those two flows names them:
|
|
5426
5497
|
* `{ onDeliveryError: { passwordResetToken: 'rethrow', emailChangeVerification: 'rethrow' } }`.
|
|
5427
|
-
* A bare `'rethrow'` also works and opts in every message.
|
|
5428
|
-
* those two flows are two of the
|
|
5498
|
+
* A bare `'rethrow'` also works and opts in every message. Six of them render a credential, and
|
|
5499
|
+
* those two flows are two of the six — so the bare form reaches four further credential-bearing
|
|
5429
5500
|
* paths, a wider trade than either flow asks for. The default optimizes for the common case: a
|
|
5430
5501
|
* transient channel outage must not fail the user's action.
|
|
5431
5502
|
*
|
|
@@ -5446,7 +5517,7 @@ declare class DefaultAuthEmailProvider implements IEmailProvider {
|
|
|
5446
5517
|
*
|
|
5447
5518
|
* A `Map`, not the plain object the option accepts. An object lookup walks the prototype chain,
|
|
5448
5519
|
* so `policy['toString']` answers with a function rather than `undefined` — unreachable here,
|
|
5449
|
-
* because the key is a closed union of
|
|
5520
|
+
* because the key is a closed union of literals this file writes, but "the key cannot be
|
|
5450
5521
|
* dangerous" is a property of today's call sites and not of the lookup. A `Map` has no prototype
|
|
5451
5522
|
* chain to walk, which makes it a property of the data structure instead.
|
|
5452
5523
|
*/
|
|
@@ -5476,6 +5547,7 @@ declare class DefaultAuthEmailProvider implements IEmailProvider {
|
|
|
5476
5547
|
sendNewSessionAlert(tenantId: string, email: string, sessionInfo: SessionAlertInfo, locale?: string): Promise<void>;
|
|
5477
5548
|
/** @inheritdoc */
|
|
5478
5549
|
sendInvitation(tenantId: string, email: string, inviteData: InviteData, locale?: string): Promise<void>;
|
|
5550
|
+
sendWorkspaceInvitation(tenantId: string, email: string, data: WorkspaceInviteData, locale?: string): Promise<void>;
|
|
5479
5551
|
/**
|
|
5480
5552
|
* Renders the body to HTML (unless the message already carries its own), hands the message to the
|
|
5481
5553
|
* channel, and swallows any delivery error.
|
|
@@ -12211,6 +12283,23 @@ declare class AuthTokenVerifierService {
|
|
|
12211
12283
|
interface MyWorkspaces extends MembershipPage<MembershipWithWorkspace> {
|
|
12212
12284
|
lastActiveWorkspaceId: string | null;
|
|
12213
12285
|
}
|
|
12286
|
+
/**
|
|
12287
|
+
* Thrown by {@link MembershipService.removeAllForUser} when the memberships were removed but the
|
|
12288
|
+
* cached access of some of them could not be dropped. The removal is committed, so calling it again
|
|
12289
|
+
* finds nothing to remove: the host re-runs `WorkspaceAccessService.invalidateMembership` for each
|
|
12290
|
+
* entry of {@link MembershipBumpFailedError.failed}, or waits out `membershipCacheTtlSeconds`.
|
|
12291
|
+
*/
|
|
12292
|
+
declare class MembershipBumpFailedError extends Error {
|
|
12293
|
+
readonly removed: readonly RemovedMembership[];
|
|
12294
|
+
readonly failed: readonly RemovedMembership[];
|
|
12295
|
+
readonly cause: unknown;
|
|
12296
|
+
/**
|
|
12297
|
+
* @param removed - Every membership the removal deleted.
|
|
12298
|
+
* @param failed - The ones whose cached access could not be dropped.
|
|
12299
|
+
* @param cause - The first error a bump failed with.
|
|
12300
|
+
*/
|
|
12301
|
+
constructor(removed: readonly RemovedMembership[], failed: readonly RemovedMembership[], cause: unknown);
|
|
12302
|
+
}
|
|
12214
12303
|
/**
|
|
12215
12304
|
* Changes who belongs to a workspace and what they may do there.
|
|
12216
12305
|
*
|
|
@@ -12279,6 +12368,27 @@ declare class MembershipService {
|
|
|
12279
12368
|
cursor?: string;
|
|
12280
12369
|
limit?: number;
|
|
12281
12370
|
}): Promise<MembershipPage<AuthWorkspace>>;
|
|
12371
|
+
/**
|
|
12372
|
+
* Removes every membership of an account that is about to be deleted or anonymised: in every
|
|
12373
|
+
* membership status and every workspace, with one `member.removed` event per removal and the
|
|
12374
|
+
* cached access of each dropped.
|
|
12375
|
+
*
|
|
12376
|
+
* Refuses while the account is the only owner of an active or suspended workspace, so the host can
|
|
12377
|
+
* transfer ownership or schedule deletion first. A workspace pending deletion does not block:
|
|
12378
|
+
* no one can finalize it early, so the owner's membership there is removed too, the workspace can
|
|
12379
|
+
* no longer be restored, and the host's finalize job deletes it when its grace period ends.
|
|
12380
|
+
*
|
|
12381
|
+
* @param tenantId - The account's tenant.
|
|
12382
|
+
* @param userId - The account.
|
|
12383
|
+
* @param actorUserId - Who authorizes the deletion: the account, an administrator, or `null` for a
|
|
12384
|
+
* job. No workspace role does, so none is checked.
|
|
12385
|
+
* @param context - Request metadata for the hook.
|
|
12386
|
+
* @returns The memberships removed.
|
|
12387
|
+
* @throws {AuthException} `auth.last_owner`, with `details.workspaces`, while a workspace would be
|
|
12388
|
+
* left without an owner; nothing is removed.
|
|
12389
|
+
* @throws {MembershipBumpFailedError} When the removal committed but a cache bump failed.
|
|
12390
|
+
*/
|
|
12391
|
+
removeAllForUser(tenantId: string, userId: string, actorUserId: string | null, context: HookContext): Promise<RemovedMembership[]>;
|
|
12282
12392
|
/**
|
|
12283
12393
|
* Changes a member's role.
|
|
12284
12394
|
*
|
|
@@ -12394,6 +12504,11 @@ declare class MembershipService {
|
|
|
12394
12504
|
* only on a role it includes and does not itself hold.
|
|
12395
12505
|
*/
|
|
12396
12506
|
private outranks;
|
|
12507
|
+
/**
|
|
12508
|
+
* The workspaces that stop an account deletion: those the account alone owns, except the ones
|
|
12509
|
+
* pending deletion or deleted. Stops reading pages once a full page of them is known.
|
|
12510
|
+
*/
|
|
12511
|
+
private soleOwnedBlocking;
|
|
12397
12512
|
private removeWith;
|
|
12398
12513
|
/**
|
|
12399
12514
|
* Turns a guarded write's outcome into an error, or ends the affected members' cached access.
|
|
@@ -14273,5 +14388,5 @@ declare class WorkspaceInvitationService {
|
|
|
14273
14388
|
private activeWorkspace;
|
|
14274
14389
|
}
|
|
14275
14390
|
|
|
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 };
|
|
14391
|
+
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 };
|
|
14392
|
+
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
|
@@ -457,6 +457,41 @@ function resolveRegistration(userOptions) {
|
|
|
457
457
|
return mode;
|
|
458
458
|
}
|
|
459
459
|
__name(resolveRegistration, "resolveRegistration");
|
|
460
|
+
function assertInvitationControllers(resolved, workspaceController, tenantController) {
|
|
461
|
+
const workspacesEnabled = resolved.workspaces !== void 0;
|
|
462
|
+
if (workspaceController && !workspacesEnabled) {
|
|
463
|
+
throw new Error("[BymaxAuthModule] controllers.workspaceInvitations: true requires workspaces.enabled: true and both workspace repository providers in extraProviders.");
|
|
464
|
+
}
|
|
465
|
+
if (resolved.registration !== "invitation-only") return;
|
|
466
|
+
const workspacePath = missingPieces([
|
|
467
|
+
[
|
|
468
|
+
"workspaces.enabled",
|
|
469
|
+
workspacesEnabled
|
|
470
|
+
],
|
|
471
|
+
[
|
|
472
|
+
"controllers.workspaceInvitations",
|
|
473
|
+
workspaceController
|
|
474
|
+
]
|
|
475
|
+
]);
|
|
476
|
+
const tenantPath = missingPieces([
|
|
477
|
+
[
|
|
478
|
+
"invitations.enabled",
|
|
479
|
+
resolved.invitations.enabled
|
|
480
|
+
],
|
|
481
|
+
[
|
|
482
|
+
"controllers.invitations",
|
|
483
|
+
tenantController
|
|
484
|
+
]
|
|
485
|
+
]);
|
|
486
|
+
if (workspacePath.length > 0 && tenantPath.length > 0) {
|
|
487
|
+
throw new Error(`[BymaxAuthModule] registration: 'invitation-only' leaves no way to create an account. Enable one invitation path: workspaces (missing: ${workspacePath.join(", ")}) or tenant invitations (missing: ${tenantPath.join(", ")}).`);
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
__name(assertInvitationControllers, "assertInvitationControllers");
|
|
491
|
+
function missingPieces(pieces) {
|
|
492
|
+
return pieces.filter(([, on]) => !on).map(([name]) => name);
|
|
493
|
+
}
|
|
494
|
+
__name(missingPieces, "missingPieces");
|
|
460
495
|
function resolveWorkspaceOptions(userOptions) {
|
|
461
496
|
const group = userOptions.workspaces;
|
|
462
497
|
if (group?.enabled !== true) return void 0;
|
|
@@ -15958,6 +15993,23 @@ function pageSize(limit) {
|
|
|
15958
15993
|
return Math.min(Math.max(limit, 1), MAX_PAGE_SIZE);
|
|
15959
15994
|
}
|
|
15960
15995
|
__name(pageSize, "pageSize");
|
|
15996
|
+
var MembershipBumpFailedError = class extends Error {
|
|
15997
|
+
static {
|
|
15998
|
+
__name(this, "MembershipBumpFailedError");
|
|
15999
|
+
}
|
|
16000
|
+
removed;
|
|
16001
|
+
failed;
|
|
16002
|
+
cause;
|
|
16003
|
+
/**
|
|
16004
|
+
* @param removed - Every membership the removal deleted.
|
|
16005
|
+
* @param failed - The ones whose cached access could not be dropped.
|
|
16006
|
+
* @param cause - The first error a bump failed with.
|
|
16007
|
+
*/
|
|
16008
|
+
constructor(removed, failed, cause) {
|
|
16009
|
+
super("The memberships were removed but their cached access could not be dropped."), this.removed = removed, this.failed = failed, this.cause = cause;
|
|
16010
|
+
this.name = "MembershipBumpFailedError";
|
|
16011
|
+
}
|
|
16012
|
+
};
|
|
15961
16013
|
var MembershipService = class {
|
|
15962
16014
|
static {
|
|
15963
16015
|
__name(this, "MembershipService");
|
|
@@ -16039,6 +16091,76 @@ var MembershipService = class {
|
|
|
16039
16091
|
});
|
|
16040
16092
|
}
|
|
16041
16093
|
/**
|
|
16094
|
+
* Removes every membership of an account that is about to be deleted or anonymised: in every
|
|
16095
|
+
* membership status and every workspace, with one `member.removed` event per removal and the
|
|
16096
|
+
* cached access of each dropped.
|
|
16097
|
+
*
|
|
16098
|
+
* Refuses while the account is the only owner of an active or suspended workspace, so the host can
|
|
16099
|
+
* transfer ownership or schedule deletion first. A workspace pending deletion does not block:
|
|
16100
|
+
* no one can finalize it early, so the owner's membership there is removed too, the workspace can
|
|
16101
|
+
* no longer be restored, and the host's finalize job deletes it when its grace period ends.
|
|
16102
|
+
*
|
|
16103
|
+
* @param tenantId - The account's tenant.
|
|
16104
|
+
* @param userId - The account.
|
|
16105
|
+
* @param actorUserId - Who authorizes the deletion: the account, an administrator, or `null` for a
|
|
16106
|
+
* job. No workspace role does, so none is checked.
|
|
16107
|
+
* @param context - Request metadata for the hook.
|
|
16108
|
+
* @returns The memberships removed.
|
|
16109
|
+
* @throws {AuthException} `auth.last_owner`, with `details.workspaces`, while a workspace would be
|
|
16110
|
+
* left without an owner; nothing is removed.
|
|
16111
|
+
* @throws {MembershipBumpFailedError} When the removal committed but a cache bump failed.
|
|
16112
|
+
*/
|
|
16113
|
+
async removeAllForUser(tenantId, userId, actorUserId, context) {
|
|
16114
|
+
const blocking = await this.soleOwnedBlocking(tenantId, userId);
|
|
16115
|
+
if (blocking.length > 0) throw new AuthException(AUTH_ERROR_CODES.LAST_OWNER, {
|
|
16116
|
+
workspaces: blocking
|
|
16117
|
+
});
|
|
16118
|
+
const at = now();
|
|
16119
|
+
const outcome = await this.memberships.removeAllForUser({
|
|
16120
|
+
tenantId,
|
|
16121
|
+
userId,
|
|
16122
|
+
ownerRole: this.group.roles.ownerRole,
|
|
16123
|
+
audit: {
|
|
16124
|
+
type: "member.removed",
|
|
16125
|
+
tenantId,
|
|
16126
|
+
actorUserId,
|
|
16127
|
+
userId,
|
|
16128
|
+
at
|
|
16129
|
+
}
|
|
16130
|
+
});
|
|
16131
|
+
if (outcome.result === "last_owner") {
|
|
16132
|
+
throw new AuthException(AUTH_ERROR_CODES.LAST_OWNER, {
|
|
16133
|
+
workspaces: outcome.workspaceIds.map((id) => ({
|
|
16134
|
+
id
|
|
16135
|
+
}))
|
|
16136
|
+
});
|
|
16137
|
+
}
|
|
16138
|
+
const failed = [];
|
|
16139
|
+
let cause;
|
|
16140
|
+
for (const removed of outcome.removed) {
|
|
16141
|
+
this.events.emit({
|
|
16142
|
+
type: "member.removed",
|
|
16143
|
+
tenantId,
|
|
16144
|
+
workspaceId: removed.workspaceId,
|
|
16145
|
+
actorUserId,
|
|
16146
|
+
userId,
|
|
16147
|
+
at
|
|
16148
|
+
}, context);
|
|
16149
|
+
try {
|
|
16150
|
+
await this.access.invalidateMembership({
|
|
16151
|
+
tenantId,
|
|
16152
|
+
workspaceId: removed.workspaceId,
|
|
16153
|
+
userId
|
|
16154
|
+
});
|
|
16155
|
+
} catch (error) {
|
|
16156
|
+
if (failed.length === 0) cause = error;
|
|
16157
|
+
failed.push(removed);
|
|
16158
|
+
}
|
|
16159
|
+
}
|
|
16160
|
+
if (failed.length > 0) throw new MembershipBumpFailedError(outcome.removed, failed, cause);
|
|
16161
|
+
return outcome.removed;
|
|
16162
|
+
}
|
|
16163
|
+
/**
|
|
16042
16164
|
* Changes a member's role.
|
|
16043
16165
|
*
|
|
16044
16166
|
* @param ref - The workspace.
|
|
@@ -16295,6 +16417,35 @@ var MembershipService = class {
|
|
|
16295
16417
|
const { hierarchy, ownerRole } = this.group.roles;
|
|
16296
16418
|
return actorRole === ownerRole || actorRole !== otherRole && hasRole(actorRole, otherRole, hierarchy);
|
|
16297
16419
|
}
|
|
16420
|
+
/**
|
|
16421
|
+
* The workspaces that stop an account deletion: those the account alone owns, except the ones
|
|
16422
|
+
* pending deletion or deleted. Stops reading pages once a full page of them is known.
|
|
16423
|
+
*/
|
|
16424
|
+
async soleOwnedBlocking(tenantId, userId) {
|
|
16425
|
+
const blocking = [];
|
|
16426
|
+
let cursor;
|
|
16427
|
+
do {
|
|
16428
|
+
const page = await this.memberships.listSoleOwned({
|
|
16429
|
+
tenantId,
|
|
16430
|
+
userId,
|
|
16431
|
+
ownerRole: this.group.roles.ownerRole,
|
|
16432
|
+
...cursor === void 0 ? {} : {
|
|
16433
|
+
cursor
|
|
16434
|
+
},
|
|
16435
|
+
limit: MAX_PAGE_SIZE
|
|
16436
|
+
});
|
|
16437
|
+
for (const workspace of page.items) {
|
|
16438
|
+
if (workspace.status === "pending_deletion" || workspace.status === "deleted") continue;
|
|
16439
|
+
blocking.push({
|
|
16440
|
+
id: workspace.id,
|
|
16441
|
+
name: workspace.name,
|
|
16442
|
+
status: workspace.status
|
|
16443
|
+
});
|
|
16444
|
+
}
|
|
16445
|
+
cursor = page.nextCursor ?? void 0;
|
|
16446
|
+
} while (cursor !== void 0 && blocking.length < MAX_PAGE_SIZE);
|
|
16447
|
+
return blocking.slice(0, MAX_PAGE_SIZE);
|
|
16448
|
+
}
|
|
16298
16449
|
async removeWith(ref, userId, event, context, judged2) {
|
|
16299
16450
|
const result = await this.memberships.remove({
|
|
16300
16451
|
...ref,
|
|
@@ -17486,7 +17637,8 @@ var WorkspaceInvitationService = class {
|
|
|
17486
17637
|
role: record.role,
|
|
17487
17638
|
inviteToken: token,
|
|
17488
17639
|
expiresAt: new Date(Date.parse(record.createdAt) + ttl * 1e3),
|
|
17489
|
-
accountExists
|
|
17640
|
+
accountExists,
|
|
17641
|
+
kind: record.kind
|
|
17490
17642
|
});
|
|
17491
17643
|
} catch (err) {
|
|
17492
17644
|
throw new Error(describeChannelStatus(err));
|
|
@@ -23687,9 +23839,7 @@ var BymaxAuthModule = class _BymaxAuthModule {
|
|
|
23687
23839
|
if (includeWorkspaceController && resolved.workspaces === void 0) {
|
|
23688
23840
|
throw new Error("[BymaxAuthModule] controllers.workspaces: true requires workspaces.enabled: true and both workspace repository providers in extraProviders.");
|
|
23689
23841
|
}
|
|
23690
|
-
|
|
23691
|
-
throw new Error("[BymaxAuthModule] controllers.workspaceInvitations: true requires workspaces.enabled: true and both workspace repository providers in extraProviders.");
|
|
23692
|
-
}
|
|
23842
|
+
assertInvitationControllers(resolved, includeWorkspaceInvitations, includeInvitations);
|
|
23693
23843
|
if (resolved.apiKeys.auditMode === "required" && cannotAuditApiKeys(extraProviders)) {
|
|
23694
23844
|
throw new Error("[BymaxAuthModule] apiKeys.auditMode: 'required' needs an onApiKeyRequest hook, and the BYMAX_AUTH_HOOKS provider has none. Implement it, or use auditMode: 'best-effort'.");
|
|
23695
23845
|
}
|
|
@@ -24066,29 +24216,39 @@ function authDocumentSecurity({ guard, tokenDelivery }) {
|
|
|
24066
24216
|
return Object.freeze(schemes.map(requirementFor));
|
|
24067
24217
|
}
|
|
24068
24218
|
__name(authDocumentSecurity, "authDocumentSecurity");
|
|
24069
|
-
|
|
24070
|
-
|
|
24071
|
-
"passwordResetOtp",
|
|
24072
|
-
"emailVerificationOtp",
|
|
24073
|
-
"passwordChanged",
|
|
24074
|
-
"emailChangeVerification",
|
|
24075
|
-
"emailChanged",
|
|
24076
|
-
"mfaEnabled",
|
|
24077
|
-
"mfaDisabled",
|
|
24078
|
-
"newSessionAlert",
|
|
24079
|
-
"invitation"
|
|
24080
|
-
];
|
|
24081
|
-
Object.freeze(AUTH_EMAIL_KINDS);
|
|
24082
|
-
var CREDENTIAL_BEARING_KINDS = /* @__PURE__ */ new Set([
|
|
24083
|
-
"passwordResetToken",
|
|
24084
|
-
"passwordResetOtp",
|
|
24085
|
-
"emailVerificationOtp",
|
|
24086
|
-
"emailChangeVerification",
|
|
24087
|
-
"invitation"
|
|
24088
|
-
]);
|
|
24089
|
-
var KNOWN_EMAIL_KINDS = new Set(AUTH_EMAIL_KINDS);
|
|
24219
|
+
|
|
24220
|
+
// src/server/providers/default-auth-email.messages.ts
|
|
24090
24221
|
var CODE_VALIDITY_TEXT = "It expires shortly, so use it soon.";
|
|
24091
24222
|
var UNEXPECTED_CHANGE_TEXT = "If this was not you, secure your account immediately: change your password and sign out of every session.";
|
|
24223
|
+
function hasInviter(invite) {
|
|
24224
|
+
return invite.inviterName.trim() !== "";
|
|
24225
|
+
}
|
|
24226
|
+
__name(hasInviter, "hasInviter");
|
|
24227
|
+
function workspaceInvitationSubject(invite) {
|
|
24228
|
+
if (invite.kind === "member") {
|
|
24229
|
+
return `${invite.inviterName} invited you to ${invite.workspaceName}`;
|
|
24230
|
+
}
|
|
24231
|
+
return hasInviter(invite) ? `${invite.inviterName} invited you to set up ${invite.workspaceName}` : `You have been invited to set up ${invite.workspaceName}`;
|
|
24232
|
+
}
|
|
24233
|
+
__name(workspaceInvitationSubject, "workspaceInvitationSubject");
|
|
24234
|
+
function workspaceInvitationOpening(invite) {
|
|
24235
|
+
if (invite.kind === "member") {
|
|
24236
|
+
return `${invite.inviterName} invited you to the workspace ${invite.workspaceName} as ${invite.role}.`;
|
|
24237
|
+
}
|
|
24238
|
+
const subject = hasInviter(invite) ? `${invite.inviterName} invited you` : "You have been invited";
|
|
24239
|
+
return `${subject} to set up the workspace ${invite.workspaceName} as its owner.`;
|
|
24240
|
+
}
|
|
24241
|
+
__name(workspaceInvitationOpening, "workspaceInvitationOpening");
|
|
24242
|
+
function workspaceInvitationText(invite) {
|
|
24243
|
+
const step = invite.accountExists ? "Sign in" : "Create your account";
|
|
24244
|
+
return [
|
|
24245
|
+
workspaceInvitationOpening(invite),
|
|
24246
|
+
`${step} and use this token to accept: ${invite.inviteToken}`,
|
|
24247
|
+
`It expires on ${invite.expiresAt.toISOString()}.`,
|
|
24248
|
+
"If you were not expecting this invitation, ignore this message."
|
|
24249
|
+
].join("\n\n");
|
|
24250
|
+
}
|
|
24251
|
+
__name(workspaceInvitationText, "workspaceInvitationText");
|
|
24092
24252
|
var DEFAULT_MESSAGES = {
|
|
24093
24253
|
passwordResetToken: /* @__PURE__ */ __name(({ token }) => ({
|
|
24094
24254
|
subject: "Reset your password",
|
|
@@ -24165,8 +24325,37 @@ Use this token to accept: ${invite.inviteToken}
|
|
|
24165
24325
|
It expires on ${invite.expiresAt.toISOString()}.
|
|
24166
24326
|
|
|
24167
24327
|
If you were not expecting this invitation, ignore this message.`
|
|
24168
|
-
}), "invitation")
|
|
24328
|
+
}), "invitation"),
|
|
24329
|
+
workspaceInvitation: /* @__PURE__ */ __name(({ invite }) => ({
|
|
24330
|
+
subject: workspaceInvitationSubject(invite),
|
|
24331
|
+
text: workspaceInvitationText(invite)
|
|
24332
|
+
}), "workspaceInvitation")
|
|
24169
24333
|
};
|
|
24334
|
+
|
|
24335
|
+
// src/server/providers/default-auth-email.provider.ts
|
|
24336
|
+
var AUTH_EMAIL_KINDS = [
|
|
24337
|
+
"passwordResetToken",
|
|
24338
|
+
"passwordResetOtp",
|
|
24339
|
+
"emailVerificationOtp",
|
|
24340
|
+
"passwordChanged",
|
|
24341
|
+
"emailChangeVerification",
|
|
24342
|
+
"emailChanged",
|
|
24343
|
+
"mfaEnabled",
|
|
24344
|
+
"mfaDisabled",
|
|
24345
|
+
"newSessionAlert",
|
|
24346
|
+
"invitation",
|
|
24347
|
+
"workspaceInvitation"
|
|
24348
|
+
];
|
|
24349
|
+
Object.freeze(AUTH_EMAIL_KINDS);
|
|
24350
|
+
var CREDENTIAL_BEARING_KINDS = /* @__PURE__ */ new Set([
|
|
24351
|
+
"passwordResetToken",
|
|
24352
|
+
"passwordResetOtp",
|
|
24353
|
+
"emailVerificationOtp",
|
|
24354
|
+
"emailChangeVerification",
|
|
24355
|
+
"invitation",
|
|
24356
|
+
"workspaceInvitation"
|
|
24357
|
+
]);
|
|
24358
|
+
var KNOWN_EMAIL_KINDS = new Set(AUTH_EMAIL_KINDS);
|
|
24170
24359
|
function escapeHtml(value) {
|
|
24171
24360
|
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
24172
24361
|
}
|
|
@@ -24193,7 +24382,7 @@ var DefaultAuthEmailProvider = class _DefaultAuthEmailProvider {
|
|
|
24193
24382
|
*
|
|
24194
24383
|
* A `Map`, not the plain object the option accepts. An object lookup walks the prototype chain,
|
|
24195
24384
|
* so `policy['toString']` answers with a function rather than `undefined` — unreachable here,
|
|
24196
|
-
* because the key is a closed union of
|
|
24385
|
+
* because the key is a closed union of literals this file writes, but "the key cannot be
|
|
24197
24386
|
* dangerous" is a property of today's call sites and not of the lookup. A `Map` has no prototype
|
|
24198
24387
|
* chain to walk, which makes it a property of the data structure instead.
|
|
24199
24388
|
*/
|
|
@@ -24319,6 +24508,14 @@ var DefaultAuthEmailProvider = class _DefaultAuthEmailProvider {
|
|
|
24319
24508
|
locale
|
|
24320
24509
|
}), "invitation");
|
|
24321
24510
|
}
|
|
24511
|
+
async sendWorkspaceInvitation(tenantId, email, data, locale) {
|
|
24512
|
+
await this.deliver(tenantId, email, this.messages.workspaceInvitation({
|
|
24513
|
+
tenantId,
|
|
24514
|
+
email,
|
|
24515
|
+
invite: data,
|
|
24516
|
+
locale
|
|
24517
|
+
}), "workspaceInvitation");
|
|
24518
|
+
}
|
|
24322
24519
|
/**
|
|
24323
24520
|
* Renders the body to HTML (unless the message already carries its own), hands the message to the
|
|
24324
24521
|
* channel, and swallows any delivery error.
|
|
@@ -24990,4 +25187,4 @@ function stampJobContext(workspace) {
|
|
|
24990
25187
|
}
|
|
24991
25188
|
__name(stampJobContext, "stampJobContext");
|
|
24992
25189
|
|
|
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 };
|
|
25190
|
+
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;
|