1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-20 10:13:31 +00:00

Merge branch 'master' into EC-598-beeep-properly-store-passkeys-in-bitwarden

This commit is contained in:
Andreas Coroiu
2023-01-25 15:24:42 +01:00
1208 changed files with 94078 additions and 16018 deletions

View File

@@ -0,0 +1,8 @@
import { Observable } from "rxjs";
import { ProfileResponse } from "../../models/response/profile.response";
export abstract class AvatarUpdateService {
avatarUpdate$ = new Observable<string | null>();
abstract pushUpdate(color: string): Promise<ProfileResponse | void>;
abstract loadColorFromState(): Promise<string | null>;
}

View File

@@ -11,6 +11,7 @@ import { CipherCreateRequest } from "../models/request/cipher-create.request";
import { CipherPartialRequest } from "../models/request/cipher-partial.request";
import { CipherShareRequest } from "../models/request/cipher-share.request";
import { CipherRequest } from "../models/request/cipher.request";
import { CollectionBulkDeleteRequest } from "../models/request/collection-bulk-delete.request";
import { CollectionRequest } from "../models/request/collection.request";
import { DeleteRecoverRequest } from "../models/request/delete-recover.request";
import { DeviceVerificationRequest } from "../models/request/device-verification.request";
@@ -22,7 +23,6 @@ import { EmergencyAccessInviteRequest } from "../models/request/emergency-access
import { EmergencyAccessPasswordRequest } from "../models/request/emergency-access-password.request";
import { EmergencyAccessUpdateRequest } from "../models/request/emergency-access-update.request";
import { EventRequest } from "../models/request/event.request";
import { GroupRequest } from "../models/request/group.request";
import { IapCheckRequest } from "../models/request/iap-check.request";
import { PasswordTokenRequest } from "../models/request/identity-token/password-token.request";
import { SsoTokenRequest } from "../models/request/identity-token/sso-token.request";
@@ -34,15 +34,6 @@ import { KeyConnectorUserKeyRequest } from "../models/request/key-connector-user
import { KeysRequest } from "../models/request/keys.request";
import { OrganizationConnectionRequest } from "../models/request/organization-connection.request";
import { OrganizationImportRequest } from "../models/request/organization-import.request";
import { OrganizationUserAcceptRequest } from "../models/request/organization-user-accept.request";
import { OrganizationUserBulkConfirmRequest } from "../models/request/organization-user-bulk-confirm.request";
import { OrganizationUserBulkRequest } from "../models/request/organization-user-bulk.request";
import { OrganizationUserConfirmRequest } from "../models/request/organization-user-confirm.request";
import { OrganizationUserInviteRequest } from "../models/request/organization-user-invite.request";
import { OrganizationUserResetPasswordEnrollmentRequest } from "../models/request/organization-user-reset-password-enrollment.request";
import { OrganizationUserResetPasswordRequest } from "../models/request/organization-user-reset-password.request";
import { OrganizationUserUpdateGroupsRequest } from "../models/request/organization-user-update-groups.request";
import { OrganizationUserUpdateRequest } from "../models/request/organization-user-update.request";
import { OrganizationSponsorshipCreateRequest } from "../models/request/organization/organization-sponsorship-create.request";
import { OrganizationSponsorshipRedeemRequest } from "../models/request/organization/organization-sponsorship-redeem.request";
import { PasswordHintRequest } from "../models/request/password-hint.request";
@@ -71,6 +62,7 @@ import { TaxInfoUpdateRequest } from "../models/request/tax-info-update.request"
import { TwoFactorEmailRequest } from "../models/request/two-factor-email.request";
import { TwoFactorProviderRequest } from "../models/request/two-factor-provider.request";
import { TwoFactorRecoveryRequest } from "../models/request/two-factor-recovery.request";
import { UpdateAvatarRequest } from "../models/request/update-avatar.request";
import { UpdateDomainsRequest } from "../models/request/update-domains.request";
import { UpdateKeyRequest } from "../models/request/update-key.request";
import { UpdateProfileRequest } from "../models/request/update-profile.request";
@@ -93,7 +85,7 @@ import { BillingPaymentResponse } from "../models/response/billing-payment.respo
import { BreachAccountResponse } from "../models/response/breach-account.response";
import { CipherResponse } from "../models/response/cipher.response";
import {
CollectionGroupDetailsResponse,
CollectionAccessDetailsResponse,
CollectionResponse,
} from "../models/response/collection.response";
import { DeviceVerificationResponse } from "../models/response/device-verification.response";
@@ -105,7 +97,6 @@ import {
EmergencyAccessViewResponse,
} from "../models/response/emergency-access.response";
import { EventResponse } from "../models/response/event.response";
import { GroupDetailsResponse, GroupResponse } from "../models/response/group.response";
import { IdentityCaptchaResponse } from "../models/response/identity-captcha.response";
import { IdentityTokenResponse } from "../models/response/identity-token.response";
import { IdentityTwoFactorResponse } from "../models/response/identity-two-factor.response";
@@ -117,13 +108,6 @@ import {
} from "../models/response/organization-connection.response";
import { OrganizationExportResponse } from "../models/response/organization-export.response";
import { OrganizationSponsorshipSyncStatusResponse } from "../models/response/organization-sponsorship-sync-status.response";
import { OrganizationUserBulkPublicKeyResponse } from "../models/response/organization-user-bulk-public-key.response";
import { OrganizationUserBulkResponse } from "../models/response/organization-user-bulk.response";
import {
OrganizationUserDetailsResponse,
OrganizationUserUserDetailsResponse,
OrganizationUserResetPasswordDetailsReponse,
} from "../models/response/organization-user.response";
import { PaymentResponse } from "../models/response/payment.response";
import { PlanResponse } from "../models/response/plan.response";
import { PolicyResponse } from "../models/response/policy.response";
@@ -136,8 +120,8 @@ import {
import { ProviderUserBulkPublicKeyResponse } from "../models/response/provider/provider-user-bulk-public-key.response";
import { ProviderUserBulkResponse } from "../models/response/provider/provider-user-bulk.response";
import {
ProviderUserUserDetailsResponse,
ProviderUserResponse,
ProviderUserUserDetailsResponse,
} from "../models/response/provider/provider-user.response";
import { ProviderResponse } from "../models/response/provider/provider.response";
import { SelectionReadOnlyResponse } from "../models/response/selection-read-only.response";
@@ -156,13 +140,18 @@ import { TwoFactorEmailResponse } from "../models/response/two-factor-email.resp
import { TwoFactorProviderResponse } from "../models/response/two-factor-provider.response";
import { TwoFactorRecoverResponse } from "../models/response/two-factor-recover.response";
import {
TwoFactorWebAuthnResponse,
ChallengeResponse,
TwoFactorWebAuthnResponse,
} from "../models/response/two-factor-web-authn.response";
import { TwoFactorYubiKeyResponse } from "../models/response/two-factor-yubi-key.response";
import { UserKeyResponse } from "../models/response/user-key.response";
import { SendAccessView } from "../models/view/send-access.view";
/**
* @deprecated The `ApiService` class is deprecated and calls should be extracted into individual
* api services. The `send` method is still allowed to be used within api services. For background
* of this decision please read https://contributing.bitwarden.com/architecture/adr/refactor-api-service.
*/
export abstract class ApiService {
send: (
method: "GET" | "POST" | "PUT" | "DELETE",
@@ -183,6 +172,7 @@ export abstract class ApiService {
getUserSubscription: () => Promise<SubscriptionResponse>;
getTaxInfo: () => Promise<TaxInfoResponse>;
putProfile: (request: UpdateProfileRequest) => Promise<ProfileResponse>;
putAvatar: (request: UpdateAvatarRequest) => Promise<ProfileResponse>;
putTaxInfo: (request: TaxInfoUpdateRequest) => Promise<any>;
postPrelogin: (request: PreloginRequest) => Promise<PreloginResponse>;
postEmailToken: (request: EmailTokenRequest) => Promise<any>;
@@ -313,13 +303,16 @@ export abstract class ApiService {
) => Promise<AttachmentUploadDataResponse>;
postAttachmentFile: (id: string, attachmentId: string, data: FormData) => Promise<any>;
getCollectionDetails: (
organizationId: string,
id: string
) => Promise<CollectionGroupDetailsResponse>;
getUserCollections: () => Promise<ListResponse<CollectionResponse>>;
getCollections: (organizationId: string) => Promise<ListResponse<CollectionResponse>>;
getCollectionUsers: (organizationId: string, id: string) => Promise<SelectionReadOnlyResponse[]>;
getCollectionAccessDetails: (
organizationId: string,
id: string
) => Promise<CollectionAccessDetailsResponse>;
getManyCollectionsWithAccessDetails: (
orgId: string
) => Promise<ListResponse<CollectionAccessDetailsResponse>>;
postCollection: (
organizationId: string,
request: CollectionRequest
@@ -335,97 +328,17 @@ export abstract class ApiService {
request: CollectionRequest
) => Promise<CollectionResponse>;
deleteCollection: (organizationId: string, id: string) => Promise<any>;
deleteManyCollections: (request: CollectionBulkDeleteRequest) => Promise<any>;
deleteCollectionUser: (
organizationId: string,
id: string,
organizationUserId: string
) => Promise<any>;
getGroupDetails: (organizationId: string, id: string) => Promise<GroupDetailsResponse>;
getGroups: (organizationId: string) => Promise<ListResponse<GroupResponse>>;
getGroupUsers: (organizationId: string, id: string) => Promise<string[]>;
postGroup: (organizationId: string, request: GroupRequest) => Promise<GroupResponse>;
putGroup: (organizationId: string, id: string, request: GroupRequest) => Promise<GroupResponse>;
putGroupUsers: (organizationId: string, id: string, request: string[]) => Promise<any>;
deleteGroup: (organizationId: string, id: string) => Promise<any>;
deleteGroupUser: (organizationId: string, id: string, organizationUserId: string) => Promise<any>;
getOrganizationUser: (
organizationId: string,
id: string
) => Promise<OrganizationUserDetailsResponse>;
getOrganizationUserGroups: (organizationId: string, id: string) => Promise<string[]>;
getOrganizationUsers: (
organizationId: string
) => Promise<ListResponse<OrganizationUserUserDetailsResponse>>;
getOrganizationUserResetPasswordDetails: (
organizationId: string,
id: string
) => Promise<OrganizationUserResetPasswordDetailsReponse>;
postOrganizationUserInvite: (
organizationId: string,
request: OrganizationUserInviteRequest
) => Promise<any>;
postOrganizationUserReinvite: (organizationId: string, id: string) => Promise<any>;
postManyOrganizationUserReinvite: (
organizationId: string,
request: OrganizationUserBulkRequest
) => Promise<ListResponse<OrganizationUserBulkResponse>>;
postOrganizationUserAccept: (
organizationId: string,
id: string,
request: OrganizationUserAcceptRequest
) => Promise<any>;
postOrganizationUserConfirm: (
organizationId: string,
id: string,
request: OrganizationUserConfirmRequest
) => Promise<any>;
postOrganizationUsersPublicKey: (
organizationId: string,
request: OrganizationUserBulkRequest
) => Promise<ListResponse<OrganizationUserBulkPublicKeyResponse>>;
postOrganizationUserBulkConfirm: (
organizationId: string,
request: OrganizationUserBulkConfirmRequest
) => Promise<ListResponse<OrganizationUserBulkResponse>>;
putOrganizationUser: (
organizationId: string,
id: string,
request: OrganizationUserUpdateRequest
) => Promise<any>;
putOrganizationUserGroups: (
organizationId: string,
id: string,
request: OrganizationUserUpdateGroupsRequest
) => Promise<any>;
putOrganizationUserResetPasswordEnrollment: (
organizationId: string,
userId: string,
request: OrganizationUserResetPasswordEnrollmentRequest
) => Promise<void>;
putOrganizationUserResetPassword: (
organizationId: string,
id: string,
request: OrganizationUserResetPasswordRequest
) => Promise<any>;
deleteOrganizationUser: (organizationId: string, id: string) => Promise<any>;
deleteManyOrganizationUsers: (
organizationId: string,
request: OrganizationUserBulkRequest
) => Promise<ListResponse<OrganizationUserBulkResponse>>;
revokeOrganizationUser: (organizationId: string, id: string) => Promise<any>;
revokeManyOrganizationUsers: (
organizationId: string,
request: OrganizationUserBulkRequest
) => Promise<ListResponse<OrganizationUserBulkResponse>>;
restoreOrganizationUser: (organizationId: string, id: string) => Promise<any>;
restoreManyOrganizationUsers: (
organizationId: string,
request: OrganizationUserBulkRequest
) => Promise<ListResponse<OrganizationUserBulkResponse>>;
getSync: () => Promise<SyncResponse>;
postPublicImportDirectory: (request: OrganizationImportRequest) => Promise<any>;

View File

@@ -66,8 +66,8 @@ export abstract class CipherService {
deleteManyWithServer: (ids: string[]) => Promise<any>;
deleteAttachment: (id: string, attachmentId: string) => Promise<void>;
deleteAttachmentWithServer: (id: string, attachmentId: string) => Promise<void>;
sortCiphersByLastUsed: (a: any, b: any) => number;
sortCiphersByLastUsedThenName: (a: any, b: any) => number;
sortCiphersByLastUsed: (a: CipherView, b: CipherView) => number;
sortCiphersByLastUsedThenName: (a: CipherView, b: CipherView) => number;
getLocaleSortingFunction: () => (a: CipherView, b: CipherView) => number;
softDelete: (id: string | string[]) => Promise<any>;
softDeleteWithServer: (id: string) => Promise<any>;

View File

@@ -1,12 +0,0 @@
import { EventType } from "../enums/eventType";
export abstract class EventService {
collect: (
eventType: EventType,
cipherId?: string,
uploadImmediately?: boolean,
organizationId?: string
) => Promise<any>;
uploadEvents: (userId?: string) => Promise<any>;
clearEvents: (userId?: string) => Promise<any>;
}

View File

@@ -0,0 +1,10 @@
import { EventType } from "../../enums/eventType";
export abstract class EventCollectionService {
collect: (
eventType: EventType,
cipherId?: string,
uploadImmediately?: boolean,
organizationId?: string
) => Promise<any>;
}

View File

@@ -0,0 +1,3 @@
export abstract class EventUploadService {
uploadEvents: (userId?: string) => Promise<void>;
}

View File

@@ -12,6 +12,7 @@ export abstract class FolderService {
clearCache: () => Promise<void>;
encrypt: (model: FolderView, key?: SymmetricCryptoKey) => Promise<Folder>;
get: (id: string) => Promise<Folder>;
getAllFromState: () => Promise<Folder[]>;
/**
* @deprecated Only use in CLI!
*/

View File

@@ -6,6 +6,6 @@ export abstract class I18nService {
translationLocale: string;
collator: Intl.Collator;
localeNames: Map<string, string>;
t: (id: string, p1?: string, p2?: string, p3?: string) => string;
t: (id: string, p1?: string | number, p2?: string | number, p3?: string | number) => string;
translate: (id: string, p1?: string, p2?: string, p3?: string) => string;
}

View File

@@ -4,4 +4,5 @@ export abstract class LoginService {
setEmail: (value: string) => void;
setRememberEmail: (value: boolean) => void;
clearValues: () => void;
saveEmailSettings: () => Promise<void>;
}

View File

@@ -0,0 +1,242 @@
import { ListResponse } from "../../models/response/list.response";
import {
OrganizationUserAcceptRequest,
OrganizationUserBulkConfirmRequest,
OrganizationUserConfirmRequest,
OrganizationUserInviteRequest,
OrganizationUserResetPasswordEnrollmentRequest,
OrganizationUserResetPasswordRequest,
OrganizationUserUpdateGroupsRequest,
OrganizationUserUpdateRequest,
} from "./requests";
import {
OrganizationUserBulkPublicKeyResponse,
OrganizationUserBulkResponse,
OrganizationUserDetailsResponse,
OrganizationUserResetPasswordDetailsReponse,
OrganizationUserUserDetailsResponse,
} from "./responses";
/**
* Service for interacting with Organization Users via the API
*/
export abstract class OrganizationUserService {
/**
* Retrieve a single organization user by Id
* @param organizationId - Identifier for the user's organization
* @param id - Organization user identifier
* @param options - Options for the request
*/
abstract getOrganizationUser(
organizationId: string,
id: string,
options?: {
includeGroups?: boolean;
}
): Promise<OrganizationUserDetailsResponse>;
/**
* Retrieve a list of groups Ids the specified organization user belongs to
* @param organizationId - Identifier for the user's organization
* @param id - Organization user identifier
*/
abstract getOrganizationUserGroups(organizationId: string, id: string): Promise<string[]>;
/**
* Retrieve a list of all users that belong to the specified organization
* @param organizationId - Identifier for the organization
* @param options - Options for the request
*/
abstract getAllUsers(
organizationId: string,
options?: {
includeCollections?: boolean;
includeGroups?: boolean;
}
): Promise<ListResponse<OrganizationUserUserDetailsResponse>>;
/**
* Retrieve reset password details for the specified organization user
* @param organizationId - Identifier for the user's organization
* @param id - Organization user identifier
*/
abstract getOrganizationUserResetPasswordDetails(
organizationId: string,
id: string
): Promise<OrganizationUserResetPasswordDetailsReponse>;
/**
* Create new organization user invite(s) for the specified organization
* @param organizationId - Identifier for the organization
* @param request - New user invitation request details
*/
abstract postOrganizationUserInvite(
organizationId: string,
request: OrganizationUserInviteRequest
): Promise<void>;
/**
* Re-invite the specified organization user
* @param organizationId - Identifier for the user's organization
* @param id - Organization user identifier
*/
abstract postOrganizationUserReinvite(organizationId: string, id: string): Promise<any>;
/**
* Re-invite many organization users for the specified organization
* @param organizationId - Identifier for the organization
* @param ids - A list of organization user identifiers
* @return List of user ids, including both those that were successfully re-invited and those that had an error
*/
abstract postManyOrganizationUserReinvite(
organizationId: string,
ids: string[]
): Promise<ListResponse<OrganizationUserBulkResponse>>;
/**
* Accept an organization user invitation
* @param organizationId - Identifier for the organization to accept
* @param id - Organization user identifier
* @param request - Request details for accepting the invitation
*/
abstract postOrganizationUserAccept(
organizationId: string,
id: string,
request: OrganizationUserAcceptRequest
): Promise<void>;
/**
* Confirm an organization user that has accepted their invitation
* @param organizationId - Identifier for the organization to confirm
* @param id - Organization user identifier
* @param request - Request details for confirming the user
*/
abstract postOrganizationUserConfirm(
organizationId: string,
id: string,
request: OrganizationUserConfirmRequest
): Promise<void>;
/**
* Retrieve a list of the specified users' public keys
* @param organizationId - Identifier for the organization to accept
* @param ids - A list of organization user identifiers to retrieve public keys for
*/
abstract postOrganizationUsersPublicKey(
organizationId: string,
ids: string[]
): Promise<ListResponse<OrganizationUserBulkPublicKeyResponse>>;
/**
* Confirm many organization users that have accepted their invitations
* @param organizationId - Identifier for the organization to confirm users
* @param request - Bulk request details for confirming the user
*/
abstract postOrganizationUserBulkConfirm(
organizationId: string,
request: OrganizationUserBulkConfirmRequest
): Promise<ListResponse<OrganizationUserBulkResponse>>;
/**
* Update an organization users
* @param organizationId - Identifier for the organization the user belongs to
* @param id - Organization user identifier
* @param request - Request details for updating the user
*/
abstract putOrganizationUser(
organizationId: string,
id: string,
request: OrganizationUserUpdateRequest
): Promise<void>;
/**
* Update an organization user's groups
* @param organizationId - Identifier for the organization the user belongs to
* @param id - Organization user identifier
* @param groupIds - List of group ids to associate the user with
*/
abstract putOrganizationUserGroups(
organizationId: string,
id: string,
groupIds: OrganizationUserUpdateGroupsRequest
): Promise<void>;
/**
* Update an organization user's reset password enrollment
* @param organizationId - Identifier for the organization the user belongs to
* @param userId - Organization user identifier
* @param request - Reset password enrollment details
*/
abstract putOrganizationUserResetPasswordEnrollment(
organizationId: string,
userId: string,
request: OrganizationUserResetPasswordEnrollmentRequest
): Promise<void>;
/**
* Reset an organization user's password
* @param organizationId - Identifier for the organization the user belongs to
* @param id - Organization user identifier
* @param request - Reset password details
*/
abstract putOrganizationUserResetPassword(
organizationId: string,
id: string,
request: OrganizationUserResetPasswordRequest
): Promise<void>;
/**
* Delete an organization user
* @param organizationId - Identifier for the organization the user belongs to
* @param id - Organization user identifier
*/
abstract deleteOrganizationUser(organizationId: string, id: string): Promise<void>;
/**
* Delete many organization users
* @param organizationId - Identifier for the organization the users belongs to
* @param ids - List of organization user identifiers to delete
* @return List of user ids, including both those that were successfully deleted and those that had an error
*/
abstract deleteManyOrganizationUsers(
organizationId: string,
ids: string[]
): Promise<ListResponse<OrganizationUserBulkResponse>>;
/**
* Revoke an organization user's access to the organization
* @param organizationId - Identifier for the organization the user belongs to
* @param id - Organization user identifier
*/
abstract revokeOrganizationUser(organizationId: string, id: string): Promise<void>;
/**
* Revoke many organization users' access to the organization
* @param organizationId - Identifier for the organization the users belongs to
* @param ids - List of organization user identifiers to revoke
* @return List of user ids, including both those that were successfully revoked and those that had an error
*/
abstract revokeManyOrganizationUsers(
organizationId: string,
ids: string[]
): Promise<ListResponse<OrganizationUserBulkResponse>>;
/**
* Restore an organization user's access to the organization
* @param organizationId - Identifier for the organization the user belongs to
* @param id - Organization user identifier
*/
abstract restoreOrganizationUser(organizationId: string, id: string): Promise<void>;
/**
* Restore many organization users' access to the organization
* @param organizationId - Identifier for the organization the users belongs to
* @param ids - List of organization user identifiers to restore
* @return List of user ids, including both those that were successfully restored and those that had an error
*/
abstract restoreManyOrganizationUsers(
organizationId: string,
ids: string[]
): Promise<ListResponse<OrganizationUserBulkResponse>>;
}

View File

@@ -0,0 +1,8 @@
export * from "./organization-user-accept.request";
export * from "./organization-user-bulk-confirm.request";
export * from "./organization-user-confirm.request";
export * from "./organization-user-invite.request";
export * from "./organization-user-reset-password.request";
export * from "./organization-user-reset-password-enrollment.request";
export * from "./organization-user-update.request";
export * from "./organization-user-update-groups.request";

View File

@@ -0,0 +1,5 @@
export class OrganizationUserAcceptRequest {
token: string;
// Used to auto-enroll in master password reset
resetPasswordKey: string;
}

View File

@@ -0,0 +1,12 @@
type OrganizationUserBulkRequestEntry = {
id: string;
key: string;
};
export class OrganizationUserBulkConfirmRequest {
keys: OrganizationUserBulkRequestEntry[];
constructor(keys: OrganizationUserBulkRequestEntry[]) {
this.keys = keys;
}
}

View File

@@ -0,0 +1,3 @@
export class OrganizationUserConfirmRequest {
key: string;
}

View File

@@ -0,0 +1,12 @@
import { OrganizationUserType } from "../../../enums/organizationUserType";
import { PermissionsApi } from "../../../models/api/permissions.api";
import { SelectionReadOnlyRequest } from "../../../models/request/selection-read-only.request";
export class OrganizationUserInviteRequest {
emails: string[] = [];
type: OrganizationUserType;
accessAll: boolean;
collections: SelectionReadOnlyRequest[] = [];
groups: string[];
permissions: PermissionsApi;
}

View File

@@ -0,0 +1,5 @@
import { SecretVerificationRequest } from "../../../models/request/secret-verification.request";
export class OrganizationUserResetPasswordEnrollmentRequest extends SecretVerificationRequest {
resetPasswordKey: string;
}

View File

@@ -0,0 +1,4 @@
export class OrganizationUserResetPasswordRequest {
newMasterPasswordHash: string;
key: string;
}

View File

@@ -0,0 +1,3 @@
export class OrganizationUserUpdateGroupsRequest {
groupIds: string[] = [];
}

View File

@@ -0,0 +1,11 @@
import { OrganizationUserType } from "../../../enums/organizationUserType";
import { PermissionsApi } from "../../../models/api/permissions.api";
import { SelectionReadOnlyRequest } from "../../../models/request/selection-read-only.request";
export class OrganizationUserUpdateRequest {
type: OrganizationUserType;
accessAll: boolean;
collections: SelectionReadOnlyRequest[] = [];
groups: string[] = [];
permissions: PermissionsApi;
}

View File

@@ -0,0 +1,3 @@
export * from "./organization-user.response";
export * from "./organization-user-bulk.response";
export * from "./organization-user-bulk-public-key.response";

View File

@@ -0,0 +1,14 @@
import { BaseResponse } from "../../../models/response/base.response";
export class OrganizationUserBulkPublicKeyResponse extends BaseResponse {
id: string;
userId: string;
key: string;
constructor(response: any) {
super(response);
this.id = this.getResponseProperty("Id");
this.userId = this.getResponseProperty("UserId");
this.key = this.getResponseProperty("Key");
}
}

View File

@@ -0,0 +1,12 @@
import { BaseResponse } from "../../../models/response/base.response";
export class OrganizationUserBulkResponse extends BaseResponse {
id: string;
error: string;
constructor(response: any) {
super(response);
this.id = this.getResponseProperty("Id");
this.error = this.getResponseProperty("Error");
}
}

View File

@@ -0,0 +1,74 @@
import { KdfType } from "../../../enums/kdfType";
import { OrganizationUserStatusType } from "../../../enums/organizationUserStatusType";
import { OrganizationUserType } from "../../../enums/organizationUserType";
import { PermissionsApi } from "../../../models/api/permissions.api";
import { BaseResponse } from "../../../models/response/base.response";
import { SelectionReadOnlyResponse } from "../../../models/response/selection-read-only.response";
export class OrganizationUserResponse extends BaseResponse {
id: string;
userId: string;
type: OrganizationUserType;
status: OrganizationUserStatusType;
accessAll: boolean;
permissions: PermissionsApi;
resetPasswordEnrolled: boolean;
collections: SelectionReadOnlyResponse[] = [];
groups: string[] = [];
constructor(response: any) {
super(response);
this.id = this.getResponseProperty("Id");
this.userId = this.getResponseProperty("UserId");
this.type = this.getResponseProperty("Type");
this.status = this.getResponseProperty("Status");
this.permissions = new PermissionsApi(this.getResponseProperty("Permissions"));
this.accessAll = this.getResponseProperty("AccessAll");
this.resetPasswordEnrolled = this.getResponseProperty("ResetPasswordEnrolled");
const collections = this.getResponseProperty("Collections");
if (collections != null) {
this.collections = collections.map((c: any) => new SelectionReadOnlyResponse(c));
}
const groups = this.getResponseProperty("Groups");
if (groups != null) {
this.groups = groups;
}
}
}
export class OrganizationUserUserDetailsResponse extends OrganizationUserResponse {
name: string;
email: string;
twoFactorEnabled: boolean;
usesKeyConnector: boolean;
constructor(response: any) {
super(response);
this.name = this.getResponseProperty("Name");
this.email = this.getResponseProperty("Email");
this.twoFactorEnabled = this.getResponseProperty("TwoFactorEnabled");
this.usesKeyConnector = this.getResponseProperty("UsesKeyConnector") ?? false;
}
}
export class OrganizationUserDetailsResponse extends OrganizationUserResponse {
constructor(response: any) {
super(response);
}
}
export class OrganizationUserResetPasswordDetailsReponse extends BaseResponse {
kdf: KdfType;
kdfIterations: number;
resetPasswordKey: string;
encryptedPrivateKey: string;
constructor(response: any) {
super(response);
this.kdf = this.getResponseProperty("Kdf");
this.kdfIterations = this.getResponseProperty("KdfIterations");
this.resetPasswordKey = this.getResponseProperty("ResetPasswordKey");
this.encryptedPrivateKey = this.getResponseProperty("EncryptedPrivateKey");
}
}

View File

@@ -1,11 +1,12 @@
import { map, Observable } from "rxjs";
import { Utils } from "../../misc/utils";
import { OrganizationData } from "../../models/data/organization.data";
import { Organization } from "../../models/domain/organization";
import { I18nService } from "../i18n.service";
export function canAccessVaultTab(org: Organization): boolean {
return org.isManager;
return org.canViewAssignedCollections || org.canViewAllCollections || org.canManageGroups;
}
export function canAccessSettingsTab(org: Organization): boolean {
@@ -34,19 +35,6 @@ export function canAccessBillingTab(org: Organization): boolean {
return org.canManageBilling;
}
export function canManageCollections(org: Organization): boolean {
return (
org.canCreateNewCollections ||
org.canEditAnyCollection ||
org.canDeleteAnyCollection ||
org.canViewAssignedCollections
);
}
export function canAccessManageTab(org: Organization): boolean {
return canAccessMembersTab(org) || canAccessGroupsTab(org) || canManageCollections(org);
}
export function canAccessOrgAdmin(org: Organization): boolean {
return (
canAccessMembersTab(org) ||
@@ -54,8 +42,7 @@ export function canAccessOrgAdmin(org: Organization): boolean {
canAccessReportingTab(org) ||
canAccessBillingTab(org) ||
canAccessSettingsTab(org) ||
canAccessVaultTab(org) ||
canAccessManageTab(org)
canAccessVaultTab(org)
);
}
@@ -69,6 +56,10 @@ export function canAccessAdmin(i18nService: I18nService) {
);
}
export function isNotProviderUser(org: Organization): boolean {
return !org.isProviderUser;
}
export abstract class OrganizationService {
organizations$: Observable<Organization[]>;
@@ -83,3 +74,7 @@ export abstract class OrganizationService {
canManageSponsorships: () => Promise<boolean>;
hasOrganizations: () => boolean;
}
export abstract class InternalOrganizationService extends OrganizationService {
replace: (organizations: { [id: string]: OrganizationData }) => Promise<void>;
}

View File

@@ -19,6 +19,7 @@ export abstract class PlatformUtilsService {
isViewOpen: () => Promise<boolean>;
launchUri: (uri: string, options?: any) => void;
getApplicationVersion: () => Promise<string>;
getApplicationVersionNumber: () => Promise<string>;
supportsWebAuthn: (win: Window) => boolean;
supportsDuo: () => boolean;
showToast: (
@@ -33,7 +34,8 @@ export abstract class PlatformUtilsService {
confirmText?: string,
cancelText?: string,
type?: string,
bodyIsHtml?: boolean
bodyIsHtml?: boolean,
target?: string
) => Promise<boolean>;
isDev: () => boolean;
isSelfHost: () => boolean;

View File

@@ -349,4 +349,7 @@ export abstract class StateService<T extends Account = Account> {
* @deprecated Do not call this directly, use ConfigService
*/
setServerConfig: (value: ServerConfigData, options?: StorageOptions) => Promise<void>;
getAvatarColor: (options?: StorageOptions) => Promise<string | null | undefined>;
setAvatarColor: (value: string, options?: StorageOptions) => Promise<void>;
}

View File

@@ -7,10 +7,11 @@ export abstract class AbstractStorageService {
abstract remove(key: string, options?: StorageOptions): Promise<void>;
}
export abstract class AbstractCachedStorageService extends AbstractStorageService {
export abstract class AbstractMemoryStorageService extends AbstractStorageService {
// Used to identify the service in the session sync decorator framework
static readonly TYPE = "MemoryStorageService";
readonly type = AbstractMemoryStorageService.TYPE;
abstract get<T>(key: string, options?: MemoryStorageOptions<T>): Promise<T>;
abstract getBypassCache<T>(key: string, options?: MemoryStorageOptions<T>): Promise<T>;
}
export interface MemoryStorageServiceInterface {
get<T>(key: string, options?: MemoryStorageOptions<T>): Promise<T>;
}