Merge branch 'renovate/all-minor-patch' into 'main'
[ProtonMail-WebClient.git] / packages / pass / lib / vaults / vault.predicates.ts
blobe20421e48376f0a03bc4a56ac24c0ef7305aebec
1 import { PassCrypto } from '@proton/pass/lib/crypto';
2 import type { ShareItem } from '@proton/pass/store/reducers';
3 import { type Share, ShareRole, ShareType } from '@proton/pass/types';
5 export const isActiveVault = <T extends Share>({ targetType, shareId }: T) =>
6     targetType === ShareType.Vault && PassCrypto.canOpenShare(shareId);
8 export const isWritableVault = <T extends Share>({ targetType, shareRoleId }: T) =>
9     targetType === ShareType.Vault && shareRoleId !== ShareRole.READ;
11 export const isOwnVault = <T extends Share>({ targetType, owner }: T) => targetType === ShareType.Vault && owner;
13 export const isSharedVault = <T extends Share>({ targetType, shared }: T) => targetType === ShareType.Vault && shared;
15 export const isVaultMemberLimitReached = ({
16     targetMaxMembers,
17     invites = [],
18     members = [],
19     newUserInvites = [],
20 }: ShareItem) => invites.length + members.length + newUserInvites.length >= targetMaxMembers;
22 export const hasNewUserInvitesReady = (vault: ShareItem<ShareType.Vault>) => vault.newUserInvitesReady > 0;