mirror of
https://github.com/bitwarden/browser
synced 2025-12-15 15:53:27 +00:00
[deps] Autofill: Update prettier to v3 (#7014)
* [deps] Autofill: Update prettier to v3 * prettier formatting updates --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Jonathan Prusik <jprusik@classynemesis.com>
This commit is contained in:
@@ -141,7 +141,7 @@ export abstract class ApiService {
|
||||
authed: boolean,
|
||||
hasResponse: boolean,
|
||||
apiUrl?: string,
|
||||
alterHeaders?: (headers: Headers) => void
|
||||
alterHeaders?: (headers: Headers) => void,
|
||||
) => Promise<any>;
|
||||
|
||||
postIdentityToken: (
|
||||
@@ -149,7 +149,7 @@ export abstract class ApiService {
|
||||
| PasswordTokenRequest
|
||||
| SsoTokenRequest
|
||||
| UserApiTokenRequest
|
||||
| WebAuthnLoginTokenRequest
|
||||
| WebAuthnLoginTokenRequest,
|
||||
) => Promise<IdentityTokenResponse | IdentityTwoFactorResponse | IdentityCaptchaResponse>;
|
||||
refreshIdentityToken: () => Promise<any>;
|
||||
|
||||
@@ -181,7 +181,7 @@ export abstract class ApiService {
|
||||
postAccountVerifyEmail: () => Promise<any>;
|
||||
postAccountVerifyEmailToken: (request: VerifyEmailRequest) => Promise<any>;
|
||||
postAccountVerifyPassword: (
|
||||
request: SecretVerificationRequest
|
||||
request: SecretVerificationRequest,
|
||||
) => Promise<MasterPasswordPolicyResponse>;
|
||||
postAccountRecoverDelete: (request: DeleteRecoverRequest) => Promise<any>;
|
||||
postAccountRecoverDeleteToken: (request: VerifyDeleteRecoverRequest) => Promise<any>;
|
||||
@@ -208,7 +208,7 @@ export abstract class ApiService {
|
||||
getAttachmentData: (
|
||||
cipherId: string,
|
||||
attachmentId: string,
|
||||
emergencyAccessId?: string
|
||||
emergencyAccessId?: string,
|
||||
) => Promise<AttachmentResponse>;
|
||||
getCiphersOrganization: (organizationId: string) => Promise<ListResponse<CipherResponse>>;
|
||||
postCipher: (request: CipherRequest) => Promise<CipherResponse>;
|
||||
@@ -234,10 +234,10 @@ export abstract class ApiService {
|
||||
putRestoreCipher: (id: string) => Promise<CipherResponse>;
|
||||
putRestoreCipherAdmin: (id: string) => Promise<CipherResponse>;
|
||||
putRestoreManyCiphers: (
|
||||
request: CipherBulkRestoreRequest
|
||||
request: CipherBulkRestoreRequest,
|
||||
) => Promise<ListResponse<CipherResponse>>;
|
||||
putRestoreManyCiphersAdmin: (
|
||||
request: CipherBulkRestoreRequest
|
||||
request: CipherBulkRestoreRequest,
|
||||
) => Promise<ListResponse<CipherResponse>>;
|
||||
|
||||
/**
|
||||
@@ -252,7 +252,7 @@ export abstract class ApiService {
|
||||
postCipherAttachmentAdminLegacy: (id: string, data: FormData) => Promise<CipherResponse>;
|
||||
postCipherAttachment: (
|
||||
id: string,
|
||||
request: AttachmentRequest
|
||||
request: AttachmentRequest,
|
||||
) => Promise<AttachmentUploadDataResponse>;
|
||||
deleteCipherAttachment: (id: string, attachmentId: string) => Promise<any>;
|
||||
deleteCipherAttachmentAdmin: (id: string, attachmentId: string) => Promise<any>;
|
||||
@@ -260,11 +260,11 @@ export abstract class ApiService {
|
||||
id: string,
|
||||
attachmentId: string,
|
||||
data: FormData,
|
||||
organizationId: string
|
||||
organizationId: string,
|
||||
) => Promise<any>;
|
||||
renewAttachmentUploadUrl: (
|
||||
id: string,
|
||||
attachmentId: string
|
||||
attachmentId: string,
|
||||
) => Promise<AttachmentUploadDataResponse>;
|
||||
postAttachmentFile: (id: string, attachmentId: string, data: FormData) => Promise<any>;
|
||||
|
||||
@@ -273,31 +273,31 @@ export abstract class ApiService {
|
||||
getCollectionUsers: (organizationId: string, id: string) => Promise<SelectionReadOnlyResponse[]>;
|
||||
getCollectionAccessDetails: (
|
||||
organizationId: string,
|
||||
id: string
|
||||
id: string,
|
||||
) => Promise<CollectionAccessDetailsResponse>;
|
||||
getManyCollectionsWithAccessDetails: (
|
||||
orgId: string
|
||||
orgId: string,
|
||||
) => Promise<ListResponse<CollectionAccessDetailsResponse>>;
|
||||
postCollection: (
|
||||
organizationId: string,
|
||||
request: CollectionRequest
|
||||
request: CollectionRequest,
|
||||
) => Promise<CollectionResponse>;
|
||||
putCollectionUsers: (
|
||||
organizationId: string,
|
||||
id: string,
|
||||
request: SelectionReadOnlyRequest[]
|
||||
request: SelectionReadOnlyRequest[],
|
||||
) => Promise<any>;
|
||||
putCollection: (
|
||||
organizationId: string,
|
||||
id: string,
|
||||
request: CollectionRequest
|
||||
request: CollectionRequest,
|
||||
) => Promise<CollectionResponse>;
|
||||
deleteCollection: (organizationId: string, id: string) => Promise<any>;
|
||||
deleteManyCollections: (organizationId: string, collectionIds: string[]) => Promise<any>;
|
||||
deleteCollectionUser: (
|
||||
organizationId: string,
|
||||
id: string,
|
||||
organizationUserId: string
|
||||
organizationUserId: string,
|
||||
) => Promise<any>;
|
||||
|
||||
getGroupUsers: (organizationId: string, id: string) => Promise<string[]>;
|
||||
@@ -312,66 +312,66 @@ export abstract class ApiService {
|
||||
|
||||
getTwoFactorProviders: () => Promise<ListResponse<TwoFactorProviderResponse>>;
|
||||
getTwoFactorOrganizationProviders: (
|
||||
organizationId: string
|
||||
organizationId: string,
|
||||
) => Promise<ListResponse<TwoFactorProviderResponse>>;
|
||||
getTwoFactorAuthenticator: (
|
||||
request: SecretVerificationRequest
|
||||
request: SecretVerificationRequest,
|
||||
) => Promise<TwoFactorAuthenticatorResponse>;
|
||||
getTwoFactorEmail: (request: SecretVerificationRequest) => Promise<TwoFactorEmailResponse>;
|
||||
getTwoFactorDuo: (request: SecretVerificationRequest) => Promise<TwoFactorDuoResponse>;
|
||||
getTwoFactorOrganizationDuo: (
|
||||
organizationId: string,
|
||||
request: SecretVerificationRequest
|
||||
request: SecretVerificationRequest,
|
||||
) => Promise<TwoFactorDuoResponse>;
|
||||
getTwoFactorYubiKey: (request: SecretVerificationRequest) => Promise<TwoFactorYubiKeyResponse>;
|
||||
getTwoFactorWebAuthn: (request: SecretVerificationRequest) => Promise<TwoFactorWebAuthnResponse>;
|
||||
getTwoFactorWebAuthnChallenge: (request: SecretVerificationRequest) => Promise<ChallengeResponse>;
|
||||
getTwoFactorRecover: (request: SecretVerificationRequest) => Promise<TwoFactorRecoverResponse>;
|
||||
putTwoFactorAuthenticator: (
|
||||
request: UpdateTwoFactorAuthenticatorRequest
|
||||
request: UpdateTwoFactorAuthenticatorRequest,
|
||||
) => Promise<TwoFactorAuthenticatorResponse>;
|
||||
putTwoFactorEmail: (request: UpdateTwoFactorEmailRequest) => Promise<TwoFactorEmailResponse>;
|
||||
putTwoFactorDuo: (request: UpdateTwoFactorDuoRequest) => Promise<TwoFactorDuoResponse>;
|
||||
putTwoFactorOrganizationDuo: (
|
||||
organizationId: string,
|
||||
request: UpdateTwoFactorDuoRequest
|
||||
request: UpdateTwoFactorDuoRequest,
|
||||
) => Promise<TwoFactorDuoResponse>;
|
||||
putTwoFactorYubiKey: (
|
||||
request: UpdateTwoFactorYubioOtpRequest
|
||||
request: UpdateTwoFactorYubioOtpRequest,
|
||||
) => Promise<TwoFactorYubiKeyResponse>;
|
||||
putTwoFactorWebAuthn: (
|
||||
request: UpdateTwoFactorWebAuthnRequest
|
||||
request: UpdateTwoFactorWebAuthnRequest,
|
||||
) => Promise<TwoFactorWebAuthnResponse>;
|
||||
deleteTwoFactorWebAuthn: (
|
||||
request: UpdateTwoFactorWebAuthnDeleteRequest
|
||||
request: UpdateTwoFactorWebAuthnDeleteRequest,
|
||||
) => Promise<TwoFactorWebAuthnResponse>;
|
||||
putTwoFactorDisable: (request: TwoFactorProviderRequest) => Promise<TwoFactorProviderResponse>;
|
||||
putTwoFactorOrganizationDisable: (
|
||||
organizationId: string,
|
||||
request: TwoFactorProviderRequest
|
||||
request: TwoFactorProviderRequest,
|
||||
) => Promise<TwoFactorProviderResponse>;
|
||||
postTwoFactorRecover: (request: TwoFactorRecoveryRequest) => Promise<any>;
|
||||
postTwoFactorEmailSetup: (request: TwoFactorEmailRequest) => Promise<any>;
|
||||
postTwoFactorEmail: (request: TwoFactorEmailRequest) => Promise<any>;
|
||||
getDeviceVerificationSettings: () => Promise<DeviceVerificationResponse>;
|
||||
putDeviceVerificationSettings: (
|
||||
request: DeviceVerificationRequest
|
||||
request: DeviceVerificationRequest,
|
||||
) => Promise<DeviceVerificationResponse>;
|
||||
|
||||
getCloudCommunicationsEnabled: () => Promise<boolean>;
|
||||
abstract getOrganizationConnection<TConfig extends OrganizationConnectionConfigApis>(
|
||||
id: string,
|
||||
type: OrganizationConnectionType,
|
||||
configType: { new (response: any): TConfig }
|
||||
configType: { new (response: any): TConfig },
|
||||
): Promise<OrganizationConnectionResponse<TConfig>>;
|
||||
abstract createOrganizationConnection<TConfig extends OrganizationConnectionConfigApis>(
|
||||
request: OrganizationConnectionRequest,
|
||||
configType: { new (response: any): TConfig }
|
||||
configType: { new (response: any): TConfig },
|
||||
): Promise<OrganizationConnectionResponse<TConfig>>;
|
||||
abstract updateOrganizationConnection<TConfig extends OrganizationConnectionConfigApis>(
|
||||
request: OrganizationConnectionRequest,
|
||||
configType: { new (response: any): TConfig },
|
||||
organizationConnectionId: string
|
||||
organizationConnectionId: string,
|
||||
): Promise<OrganizationConnectionResponse<TConfig>>;
|
||||
deleteOrganizationConnection: (id: string) => Promise<void>;
|
||||
getPlans: () => Promise<ListResponse<PlanResponse>>;
|
||||
@@ -387,46 +387,46 @@ export abstract class ApiService {
|
||||
postProviderUserReinvite: (providerId: string, id: string) => Promise<any>;
|
||||
postManyProviderUserReinvite: (
|
||||
providerId: string,
|
||||
request: ProviderUserBulkRequest
|
||||
request: ProviderUserBulkRequest,
|
||||
) => Promise<ListResponse<ProviderUserBulkResponse>>;
|
||||
postProviderUserAccept: (
|
||||
providerId: string,
|
||||
id: string,
|
||||
request: ProviderUserAcceptRequest
|
||||
request: ProviderUserAcceptRequest,
|
||||
) => Promise<any>;
|
||||
postProviderUserConfirm: (
|
||||
providerId: string,
|
||||
id: string,
|
||||
request: ProviderUserConfirmRequest
|
||||
request: ProviderUserConfirmRequest,
|
||||
) => Promise<any>;
|
||||
postProviderUsersPublicKey: (
|
||||
providerId: string,
|
||||
request: ProviderUserBulkRequest
|
||||
request: ProviderUserBulkRequest,
|
||||
) => Promise<ListResponse<ProviderUserBulkPublicKeyResponse>>;
|
||||
postProviderUserBulkConfirm: (
|
||||
providerId: string,
|
||||
request: ProviderUserBulkConfirmRequest
|
||||
request: ProviderUserBulkConfirmRequest,
|
||||
) => Promise<ListResponse<ProviderUserBulkResponse>>;
|
||||
putProviderUser: (
|
||||
providerId: string,
|
||||
id: string,
|
||||
request: ProviderUserUpdateRequest
|
||||
request: ProviderUserUpdateRequest,
|
||||
) => Promise<any>;
|
||||
deleteProviderUser: (organizationId: string, id: string) => Promise<any>;
|
||||
deleteManyProviderUsers: (
|
||||
providerId: string,
|
||||
request: ProviderUserBulkRequest
|
||||
request: ProviderUserBulkRequest,
|
||||
) => Promise<ListResponse<ProviderUserBulkResponse>>;
|
||||
getProviderClients: (
|
||||
providerId: string
|
||||
providerId: string,
|
||||
) => Promise<ListResponse<ProviderOrganizationOrganizationDetailsResponse>>;
|
||||
postProviderAddOrganization: (
|
||||
providerId: string,
|
||||
request: ProviderAddOrganizationRequest
|
||||
request: ProviderAddOrganizationRequest,
|
||||
) => Promise<any>;
|
||||
postProviderCreateOrganization: (
|
||||
providerId: string,
|
||||
request: ProviderOrganizationCreateRequest
|
||||
request: ProviderOrganizationCreateRequest,
|
||||
) => Promise<ProviderOrganizationResponse>;
|
||||
deleteProviderOrganization: (providerId: string, organizationId: string) => Promise<any>;
|
||||
|
||||
@@ -435,33 +435,33 @@ export abstract class ApiService {
|
||||
id: string,
|
||||
start: string,
|
||||
end: string,
|
||||
token: string
|
||||
token: string,
|
||||
) => Promise<ListResponse<EventResponse>>;
|
||||
getEventsOrganization: (
|
||||
id: string,
|
||||
start: string,
|
||||
end: string,
|
||||
token: string
|
||||
token: string,
|
||||
) => Promise<ListResponse<EventResponse>>;
|
||||
getEventsOrganizationUser: (
|
||||
organizationId: string,
|
||||
id: string,
|
||||
start: string,
|
||||
end: string,
|
||||
token: string
|
||||
token: string,
|
||||
) => Promise<ListResponse<EventResponse>>;
|
||||
getEventsProvider: (
|
||||
id: string,
|
||||
start: string,
|
||||
end: string,
|
||||
token: string
|
||||
token: string,
|
||||
) => Promise<ListResponse<EventResponse>>;
|
||||
getEventsProviderUser: (
|
||||
providerId: string,
|
||||
id: string,
|
||||
start: string,
|
||||
end: string,
|
||||
token: string
|
||||
token: string,
|
||||
) => Promise<ListResponse<EventResponse>>;
|
||||
postEventsCollect: (request: EventRequest[]) => Promise<any>;
|
||||
|
||||
@@ -483,24 +483,24 @@ export abstract class ApiService {
|
||||
|
||||
postCreateSponsorship: (
|
||||
sponsorshipOrgId: string,
|
||||
request: OrganizationSponsorshipCreateRequest
|
||||
request: OrganizationSponsorshipCreateRequest,
|
||||
) => Promise<void>;
|
||||
getSponsorshipSyncStatus: (
|
||||
sponsoredOrgId: string
|
||||
sponsoredOrgId: string,
|
||||
) => Promise<OrganizationSponsorshipSyncStatusResponse>;
|
||||
deleteRevokeSponsorship: (sponsoringOrganizationId: string) => Promise<void>;
|
||||
deleteRemoveSponsorship: (sponsoringOrgId: string) => Promise<void>;
|
||||
postPreValidateSponsorshipToken: (sponsorshipToken: string) => Promise<boolean>;
|
||||
postRedeemSponsorship: (
|
||||
sponsorshipToken: string,
|
||||
request: OrganizationSponsorshipRedeemRequest
|
||||
request: OrganizationSponsorshipRedeemRequest,
|
||||
) => Promise<void>;
|
||||
postResendSponsorshipOffer: (sponsoringOrgId: string) => Promise<void>;
|
||||
|
||||
getMasterKeyFromKeyConnector: (keyConnectorUrl: string) => Promise<KeyConnectorUserKeyResponse>;
|
||||
postUserKeyToKeyConnector: (
|
||||
keyConnectorUrl: string,
|
||||
request: KeyConnectorUserKeyRequest
|
||||
request: KeyConnectorUserKeyRequest,
|
||||
) => Promise<void>;
|
||||
getKeyConnectorAlive: (keyConnectorUrl: string) => Promise<void>;
|
||||
getOrganizationExport: (organizationId: string) => Promise<OrganizationExportResponse>;
|
||||
|
||||
@@ -5,6 +5,6 @@ export abstract class EventCollectionService {
|
||||
eventType: EventType,
|
||||
cipherId?: string,
|
||||
uploadImmediately?: boolean,
|
||||
organizationId?: string
|
||||
organizationId?: string,
|
||||
) => Promise<any>;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ export abstract class SearchService {
|
||||
searchCiphers: (
|
||||
query: string,
|
||||
filter?: ((cipher: CipherView) => boolean) | ((cipher: CipherView) => boolean)[],
|
||||
ciphers?: CipherView[]
|
||||
ciphers?: CipherView[],
|
||||
) => Promise<CipherView[]>;
|
||||
searchCiphersBasic: (ciphers: CipherView[], query: string, deleted?: boolean) => CipherView[];
|
||||
searchSends: (sends: SendView[], query: string) => SendView[];
|
||||
|
||||
@@ -12,7 +12,7 @@ export abstract class VaultTimeoutSettingsService {
|
||||
*/
|
||||
setVaultTimeoutOptions: (
|
||||
vaultTimeout: number,
|
||||
vaultTimeoutAction: VaultTimeoutAction
|
||||
vaultTimeoutAction: VaultTimeoutAction,
|
||||
) => Promise<void>;
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,11 +7,11 @@ export abstract class OrgDomainApiServiceAbstraction {
|
||||
getAllByOrgId: (orgId: string) => Promise<Array<OrganizationDomainResponse>>;
|
||||
getByOrgIdAndOrgDomainId: (
|
||||
orgId: string,
|
||||
orgDomainId: string
|
||||
orgDomainId: string,
|
||||
) => Promise<OrganizationDomainResponse>;
|
||||
post: (
|
||||
orgId: string,
|
||||
orgDomain: OrganizationDomainRequest
|
||||
orgDomain: OrganizationDomainRequest,
|
||||
) => Promise<OrganizationDomainResponse>;
|
||||
verify: (orgId: string, orgDomainId: string) => Promise<OrganizationDomainResponse>;
|
||||
delete: (orgId: string, orgDomainId: string) => Promise<any>;
|
||||
|
||||
@@ -34,7 +34,7 @@ export abstract class OrganizationUserService {
|
||||
id: string,
|
||||
options?: {
|
||||
includeGroups?: boolean;
|
||||
}
|
||||
},
|
||||
): Promise<OrganizationUserDetailsResponse>;
|
||||
|
||||
/**
|
||||
@@ -54,7 +54,7 @@ export abstract class OrganizationUserService {
|
||||
options?: {
|
||||
includeCollections?: boolean;
|
||||
includeGroups?: boolean;
|
||||
}
|
||||
},
|
||||
): Promise<ListResponse<OrganizationUserUserDetailsResponse>>;
|
||||
|
||||
/**
|
||||
@@ -64,7 +64,7 @@ export abstract class OrganizationUserService {
|
||||
*/
|
||||
abstract getOrganizationUserResetPasswordDetails(
|
||||
organizationId: string,
|
||||
id: string
|
||||
id: string,
|
||||
): Promise<OrganizationUserResetPasswordDetailsResponse>;
|
||||
|
||||
/**
|
||||
@@ -74,7 +74,7 @@ export abstract class OrganizationUserService {
|
||||
*/
|
||||
abstract postOrganizationUserInvite(
|
||||
organizationId: string,
|
||||
request: OrganizationUserInviteRequest
|
||||
request: OrganizationUserInviteRequest,
|
||||
): Promise<void>;
|
||||
|
||||
/**
|
||||
@@ -92,7 +92,7 @@ export abstract class OrganizationUserService {
|
||||
*/
|
||||
abstract postManyOrganizationUserReinvite(
|
||||
organizationId: string,
|
||||
ids: string[]
|
||||
ids: string[],
|
||||
): Promise<ListResponse<OrganizationUserBulkResponse>>;
|
||||
|
||||
/**
|
||||
@@ -106,7 +106,7 @@ export abstract class OrganizationUserService {
|
||||
abstract postOrganizationUserAcceptInit(
|
||||
organizationId: string,
|
||||
id: string,
|
||||
request: OrganizationUserAcceptInitRequest
|
||||
request: OrganizationUserAcceptInitRequest,
|
||||
): Promise<void>;
|
||||
|
||||
/**
|
||||
@@ -118,7 +118,7 @@ export abstract class OrganizationUserService {
|
||||
abstract postOrganizationUserAccept(
|
||||
organizationId: string,
|
||||
id: string,
|
||||
request: OrganizationUserAcceptRequest
|
||||
request: OrganizationUserAcceptRequest,
|
||||
): Promise<void>;
|
||||
|
||||
/**
|
||||
@@ -130,7 +130,7 @@ export abstract class OrganizationUserService {
|
||||
abstract postOrganizationUserConfirm(
|
||||
organizationId: string,
|
||||
id: string,
|
||||
request: OrganizationUserConfirmRequest
|
||||
request: OrganizationUserConfirmRequest,
|
||||
): Promise<void>;
|
||||
|
||||
/**
|
||||
@@ -140,7 +140,7 @@ export abstract class OrganizationUserService {
|
||||
*/
|
||||
abstract postOrganizationUsersPublicKey(
|
||||
organizationId: string,
|
||||
ids: string[]
|
||||
ids: string[],
|
||||
): Promise<ListResponse<OrganizationUserBulkPublicKeyResponse>>;
|
||||
|
||||
/**
|
||||
@@ -150,7 +150,7 @@ export abstract class OrganizationUserService {
|
||||
*/
|
||||
abstract postOrganizationUserBulkConfirm(
|
||||
organizationId: string,
|
||||
request: OrganizationUserBulkConfirmRequest
|
||||
request: OrganizationUserBulkConfirmRequest,
|
||||
): Promise<ListResponse<OrganizationUserBulkResponse>>;
|
||||
|
||||
/**
|
||||
@@ -162,7 +162,7 @@ export abstract class OrganizationUserService {
|
||||
abstract putOrganizationUser(
|
||||
organizationId: string,
|
||||
id: string,
|
||||
request: OrganizationUserUpdateRequest
|
||||
request: OrganizationUserUpdateRequest,
|
||||
): Promise<void>;
|
||||
|
||||
/**
|
||||
@@ -174,7 +174,7 @@ export abstract class OrganizationUserService {
|
||||
abstract putOrganizationUserGroups(
|
||||
organizationId: string,
|
||||
id: string,
|
||||
groupIds: OrganizationUserUpdateGroupsRequest
|
||||
groupIds: OrganizationUserUpdateGroupsRequest,
|
||||
): Promise<void>;
|
||||
|
||||
/**
|
||||
@@ -186,7 +186,7 @@ export abstract class OrganizationUserService {
|
||||
abstract putOrganizationUserResetPasswordEnrollment(
|
||||
organizationId: string,
|
||||
userId: string,
|
||||
request: OrganizationUserResetPasswordEnrollmentRequest
|
||||
request: OrganizationUserResetPasswordEnrollmentRequest,
|
||||
): Promise<void>;
|
||||
|
||||
/**
|
||||
@@ -198,7 +198,7 @@ export abstract class OrganizationUserService {
|
||||
abstract putOrganizationUserResetPassword(
|
||||
organizationId: string,
|
||||
id: string,
|
||||
request: OrganizationUserResetPasswordRequest
|
||||
request: OrganizationUserResetPasswordRequest,
|
||||
): Promise<void>;
|
||||
|
||||
/**
|
||||
@@ -209,7 +209,7 @@ export abstract class OrganizationUserService {
|
||||
*/
|
||||
abstract putOrganizationUserBulkEnableSecretsManager(
|
||||
organizationId: string,
|
||||
ids: string[]
|
||||
ids: string[],
|
||||
): Promise<void>;
|
||||
|
||||
/**
|
||||
@@ -227,7 +227,7 @@ export abstract class OrganizationUserService {
|
||||
*/
|
||||
abstract deleteManyOrganizationUsers(
|
||||
organizationId: string,
|
||||
ids: string[]
|
||||
ids: string[],
|
||||
): Promise<ListResponse<OrganizationUserBulkResponse>>;
|
||||
|
||||
/**
|
||||
@@ -245,7 +245,7 @@ export abstract class OrganizationUserService {
|
||||
*/
|
||||
abstract revokeManyOrganizationUsers(
|
||||
organizationId: string,
|
||||
ids: string[]
|
||||
ids: string[],
|
||||
): Promise<ListResponse<OrganizationUserBulkResponse>>;
|
||||
|
||||
/**
|
||||
@@ -263,6 +263,6 @@ export abstract class OrganizationUserService {
|
||||
*/
|
||||
abstract restoreManyOrganizationUsers(
|
||||
organizationId: string,
|
||||
ids: string[]
|
||||
ids: string[],
|
||||
): Promise<ListResponse<OrganizationUserBulkResponse>>;
|
||||
}
|
||||
|
||||
@@ -42,11 +42,11 @@ export class OrganizationApiServiceAbstraction {
|
||||
upgrade: (id: string, request: OrganizationUpgradeRequest) => Promise<PaymentResponse>;
|
||||
updatePasswordManagerSeats: (
|
||||
id: string,
|
||||
request: OrganizationSubscriptionUpdateRequest
|
||||
request: OrganizationSubscriptionUpdateRequest,
|
||||
) => Promise<void>;
|
||||
updateSecretsManagerSubscription: (
|
||||
id: string,
|
||||
request: OrganizationSmSubscriptionUpdateRequest
|
||||
request: OrganizationSmSubscriptionUpdateRequest,
|
||||
) => Promise<void>;
|
||||
updateSeats: (id: string, request: SeatRequest) => Promise<PaymentResponse>;
|
||||
updateStorage: (id: string, request: StorageRequest) => Promise<PaymentResponse>;
|
||||
@@ -60,7 +60,7 @@ export class OrganizationApiServiceAbstraction {
|
||||
getOrCreateApiKey: (id: string, request: OrganizationApiKeyRequest) => Promise<ApiKeyResponse>;
|
||||
getApiKeyInformation: (
|
||||
id: string,
|
||||
organizationApiKeyType?: OrganizationApiKeyType
|
||||
organizationApiKeyType?: OrganizationApiKeyType,
|
||||
) => Promise<ListResponse<OrganizationApiKeyInformationResponse>>;
|
||||
rotateApiKey: (id: string, request: OrganizationApiKeyRequest) => Promise<ApiKeyResponse>;
|
||||
getTaxInfo: (id: string) => Promise<TaxInfoResponse>;
|
||||
@@ -72,10 +72,10 @@ export class OrganizationApiServiceAbstraction {
|
||||
selfHostedSyncLicense: (id: string) => Promise<void>;
|
||||
subscribeToSecretsManager: (
|
||||
id: string,
|
||||
request: SecretsManagerSubscribeRequest
|
||||
request: SecretsManagerSubscribeRequest,
|
||||
) => Promise<ProfileOrganizationResponse>;
|
||||
updateCollectionManagement: (
|
||||
id: string,
|
||||
request: OrganizationCollectionManagementUpdateRequest
|
||||
request: OrganizationCollectionManagementUpdateRequest,
|
||||
) => Promise<OrganizationResponse>;
|
||||
}
|
||||
|
||||
@@ -53,13 +53,15 @@ export function getOrganizationById(id: string) {
|
||||
|
||||
export function canAccessAdmin(i18nService: I18nService) {
|
||||
return map<Organization[], Organization[]>((orgs) =>
|
||||
orgs.filter(canAccessOrgAdmin).sort(Utils.getSortFunction(i18nService, "name"))
|
||||
orgs.filter(canAccessOrgAdmin).sort(Utils.getSortFunction(i18nService, "name")),
|
||||
);
|
||||
}
|
||||
|
||||
export function canAccessImportExport(i18nService: I18nService) {
|
||||
return map<Organization[], Organization[]>((orgs) =>
|
||||
orgs.filter((org) => org.canAccessImportExport).sort(Utils.getSortFunction(i18nService, "name"))
|
||||
orgs
|
||||
.filter((org) => org.canAccessImportExport)
|
||||
.sort(Utils.getSortFunction(i18nService, "name")),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ export class PolicyApiServiceAbstraction {
|
||||
organizationId: string,
|
||||
token: string,
|
||||
email: string,
|
||||
organizationUserId: string
|
||||
organizationUserId: string,
|
||||
) => Promise<ListResponse<PolicyResponse>>;
|
||||
|
||||
getMasterPasswordPolicyOptsForOrgUser: (orgId: string) => Promise<MasterPasswordPolicyOptions>;
|
||||
|
||||
@@ -38,7 +38,7 @@ export abstract class PolicyService {
|
||||
*/
|
||||
policyAppliesToActiveUser$: (
|
||||
policyType: PolicyType,
|
||||
policyFilter?: (policy: Policy) => boolean
|
||||
policyFilter?: (policy: Policy) => boolean,
|
||||
) => Observable<boolean>;
|
||||
|
||||
/**
|
||||
@@ -49,7 +49,7 @@ export abstract class PolicyService {
|
||||
policyAppliesToUser: (
|
||||
policyType: PolicyType,
|
||||
policyFilter?: (policy: Policy) => boolean,
|
||||
userId?: string
|
||||
userId?: string,
|
||||
) => Promise<boolean>;
|
||||
|
||||
// Policy specific interfaces
|
||||
@@ -67,7 +67,7 @@ export abstract class PolicyService {
|
||||
evaluateMasterPassword: (
|
||||
passwordStrength: number,
|
||||
newPassword: string,
|
||||
enforcedPolicyOptions?: MasterPasswordPolicyOptions
|
||||
enforcedPolicyOptions?: MasterPasswordPolicyOptions,
|
||||
) => boolean;
|
||||
|
||||
/**
|
||||
@@ -76,7 +76,7 @@ export abstract class PolicyService {
|
||||
*/
|
||||
getResetPasswordPolicyOptions: (
|
||||
policies: Policy[],
|
||||
orgId: string
|
||||
orgId: string,
|
||||
) => [ResetPasswordPolicyOptions, boolean];
|
||||
|
||||
// Helpers
|
||||
|
||||
@@ -56,7 +56,7 @@ export class OrganizationData {
|
||||
options: {
|
||||
isMember: boolean;
|
||||
isProviderUser: boolean;
|
||||
}
|
||||
},
|
||||
) {
|
||||
this.id = response.id;
|
||||
this.name = response.name;
|
||||
|
||||
@@ -37,7 +37,10 @@ export class EncryptedOrganizationKey implements BaseEncryptedOrganizationKey {
|
||||
}
|
||||
|
||||
export class ProviderEncryptedOrganizationKey implements BaseEncryptedOrganizationKey {
|
||||
constructor(private key: string, private providerId: string) {}
|
||||
constructor(
|
||||
private key: string,
|
||||
private providerId: string,
|
||||
) {}
|
||||
|
||||
async decrypt(cryptoService: CryptoService) {
|
||||
const providerKey = await cryptoService.getProviderKey(this.providerId);
|
||||
|
||||
@@ -11,6 +11,6 @@ export class OrganizationConnectionRequest {
|
||||
public organizationId: string,
|
||||
public type: OrganizationConnectionType,
|
||||
public enabled: boolean,
|
||||
public config: OrganizationConnectionRequestConfigs
|
||||
public config: OrganizationConnectionRequestConfigs,
|
||||
) {}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,6 @@ import { OrganizationCreateRequest } from "../../../models/request/organization-
|
||||
export class ProviderOrganizationCreateRequest {
|
||||
constructor(
|
||||
public clientOwnerEmail: string,
|
||||
public organizationCreateRequest: OrganizationCreateRequest
|
||||
public organizationCreateRequest: OrganizationCreateRequest,
|
||||
) {}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import { ScimProviderType } from "../../enums";
|
||||
|
||||
export class ScimConfigRequest {
|
||||
constructor(private enabled: boolean, private scimProvider: ScimProviderType = null) {}
|
||||
constructor(
|
||||
private enabled: boolean,
|
||||
private scimProvider: ScimProviderType = null,
|
||||
) {}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import { ScimConfigApi } from "../api/scim-config.api";
|
||||
export type OrganizationConnectionConfigApis = BillingSyncConfigApi | ScimConfigApi;
|
||||
|
||||
export class OrganizationConnectionResponse<
|
||||
TConfig extends OrganizationConnectionConfigApis
|
||||
TConfig extends OrganizationConnectionConfigApis,
|
||||
> extends BaseResponse {
|
||||
id: string;
|
||||
type: OrganizationConnectionType;
|
||||
|
||||
@@ -70,10 +70,10 @@ export class OrganizationResponse extends BaseResponse {
|
||||
this.maxAutoscaleSmSeats = this.getResponseProperty("MaxAutoscaleSmSeats");
|
||||
this.maxAutoscaleSmServiceAccounts = this.getResponseProperty("MaxAutoscaleSmServiceAccounts");
|
||||
this.limitCollectionCreationDeletion = this.getResponseProperty(
|
||||
"LimitCollectionCreationDeletion"
|
||||
"LimitCollectionCreationDeletion",
|
||||
);
|
||||
this.allowAdminAccessToAllCollectionItems = this.getResponseProperty(
|
||||
"AllowAdminAccessToAllCollectionItems"
|
||||
"AllowAdminAccessToAllCollectionItems",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,13 +94,13 @@ export class ProfileOrganizationResponse extends BaseResponse {
|
||||
this.keyConnectorEnabled = this.getResponseProperty("KeyConnectorEnabled") ?? false;
|
||||
this.keyConnectorUrl = this.getResponseProperty("KeyConnectorUrl");
|
||||
const familySponsorshipLastSyncDateString = this.getResponseProperty(
|
||||
"FamilySponsorshipLastSyncDate"
|
||||
"FamilySponsorshipLastSyncDate",
|
||||
);
|
||||
if (familySponsorshipLastSyncDateString) {
|
||||
this.familySponsorshipLastSyncDate = new Date(familySponsorshipLastSyncDateString);
|
||||
}
|
||||
const familySponsorshipValidUntilString = this.getResponseProperty(
|
||||
"FamilySponsorshipValidUntil"
|
||||
"FamilySponsorshipValidUntil",
|
||||
);
|
||||
if (familySponsorshipValidUntilString) {
|
||||
this.familySponsorshipValidUntil = new Date(familySponsorshipValidUntilString);
|
||||
@@ -108,10 +108,10 @@ export class ProfileOrganizationResponse extends BaseResponse {
|
||||
this.familySponsorshipToDelete = this.getResponseProperty("FamilySponsorshipToDelete");
|
||||
this.accessSecretsManager = this.getResponseProperty("AccessSecretsManager");
|
||||
this.limitCollectionCreationDeletion = this.getResponseProperty(
|
||||
"LimitCollectionCreationDeletion"
|
||||
"LimitCollectionCreationDeletion",
|
||||
);
|
||||
this.allowAdminAccessToAllCollectionItems = this.getResponseProperty(
|
||||
"AllowAdminAccessToAllCollectionItems"
|
||||
"AllowAdminAccessToAllCollectionItems",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ const mockedOrganizationDomainSsoDetailsServerResponse = {
|
||||
};
|
||||
|
||||
const mockedOrganizationDomainSsoDetailsResponse = new OrganizationDomainSsoDetailsResponse(
|
||||
mockedOrganizationDomainSsoDetailsServerResponse
|
||||
mockedOrganizationDomainSsoDetailsServerResponse,
|
||||
);
|
||||
|
||||
describe("Org Domain API Service", () => {
|
||||
@@ -194,7 +194,7 @@ describe("Org Domain API Service", () => {
|
||||
"/organizations/domain/sso/details",
|
||||
new OrganizationDomainSsoDetailsRequest(email),
|
||||
false, //anonymous
|
||||
true
|
||||
true,
|
||||
);
|
||||
|
||||
expect(result).toEqual(mockedOrganizationDomainSsoDetailsResponse);
|
||||
|
||||
@@ -11,7 +11,7 @@ import { OrganizationDomainRequest } from "./requests/organization-domain.reques
|
||||
export class OrgDomainApiService implements OrgDomainApiServiceAbstraction {
|
||||
constructor(
|
||||
private orgDomainService: OrgDomainInternalServiceAbstraction,
|
||||
private apiService: ApiService
|
||||
private apiService: ApiService,
|
||||
) {}
|
||||
|
||||
async getAllByOrgId(orgId: string): Promise<Array<OrganizationDomainResponse>> {
|
||||
@@ -20,11 +20,11 @@ export class OrgDomainApiService implements OrgDomainApiServiceAbstraction {
|
||||
`/organizations/${orgId}/domain`,
|
||||
null,
|
||||
true,
|
||||
true
|
||||
true,
|
||||
);
|
||||
|
||||
const orgDomains = listResponse.data.map(
|
||||
(resultOrgDomain: any) => new OrganizationDomainResponse(resultOrgDomain)
|
||||
(resultOrgDomain: any) => new OrganizationDomainResponse(resultOrgDomain),
|
||||
);
|
||||
|
||||
this.orgDomainService.replace(orgDomains);
|
||||
@@ -34,14 +34,14 @@ export class OrgDomainApiService implements OrgDomainApiServiceAbstraction {
|
||||
|
||||
async getByOrgIdAndOrgDomainId(
|
||||
orgId: string,
|
||||
orgDomainId: string
|
||||
orgDomainId: string,
|
||||
): Promise<OrganizationDomainResponse> {
|
||||
const result = await this.apiService.send(
|
||||
"GET",
|
||||
`/organizations/${orgId}/domain/${orgDomainId}`,
|
||||
null,
|
||||
true,
|
||||
true
|
||||
true,
|
||||
);
|
||||
|
||||
const response = new OrganizationDomainResponse(result);
|
||||
@@ -53,14 +53,14 @@ export class OrgDomainApiService implements OrgDomainApiServiceAbstraction {
|
||||
|
||||
async post(
|
||||
orgId: string,
|
||||
orgDomainReq: OrganizationDomainRequest
|
||||
orgDomainReq: OrganizationDomainRequest,
|
||||
): Promise<OrganizationDomainResponse> {
|
||||
const result = await this.apiService.send(
|
||||
"POST",
|
||||
`/organizations/${orgId}/domain`,
|
||||
orgDomainReq,
|
||||
true,
|
||||
true
|
||||
true,
|
||||
);
|
||||
|
||||
const response = new OrganizationDomainResponse(result);
|
||||
@@ -76,7 +76,7 @@ export class OrgDomainApiService implements OrgDomainApiServiceAbstraction {
|
||||
`/organizations/${orgId}/domain/${orgDomainId}/verify`,
|
||||
null,
|
||||
true,
|
||||
true
|
||||
true,
|
||||
);
|
||||
|
||||
const response = new OrganizationDomainResponse(result);
|
||||
@@ -92,7 +92,7 @@ export class OrgDomainApiService implements OrgDomainApiServiceAbstraction {
|
||||
`/organizations/${orgId}/domain/${orgDomainId}`,
|
||||
null,
|
||||
true,
|
||||
false
|
||||
false,
|
||||
);
|
||||
this.orgDomainService.delete([orgDomainId]);
|
||||
}
|
||||
@@ -103,7 +103,7 @@ export class OrgDomainApiService implements OrgDomainApiServiceAbstraction {
|
||||
`/organizations/domain/sso/details`,
|
||||
new OrganizationDomainSsoDetailsRequest(email),
|
||||
false, // anonymous
|
||||
true
|
||||
true,
|
||||
);
|
||||
const response = new OrganizationDomainSsoDetailsResponse(result);
|
||||
|
||||
|
||||
@@ -47,14 +47,14 @@ const mockedExtraDomainServerResponse = {
|
||||
};
|
||||
|
||||
const mockedUnverifiedOrgDomainResponse = new OrganizationDomainResponse(
|
||||
mockedUnverifiedDomainServerResponse
|
||||
mockedUnverifiedDomainServerResponse,
|
||||
);
|
||||
const mockedVerifiedOrgDomainResponse = new OrganizationDomainResponse(
|
||||
mockedVerifiedDomainServerResponse
|
||||
mockedVerifiedDomainServerResponse,
|
||||
);
|
||||
|
||||
const mockedExtraOrgDomainResponse = new OrganizationDomainResponse(
|
||||
mockedExtraDomainServerResponse
|
||||
mockedExtraDomainServerResponse,
|
||||
);
|
||||
|
||||
describe("Org Domain Service", () => {
|
||||
@@ -96,11 +96,11 @@ describe("Org Domain Service", () => {
|
||||
orgDomainService.replace(orgDomains);
|
||||
|
||||
expect(orgDomainService.get(mockedVerifiedOrgDomainResponse.id)).toEqual(
|
||||
mockedVerifiedOrgDomainResponse
|
||||
mockedVerifiedOrgDomainResponse,
|
||||
);
|
||||
|
||||
expect(orgDomainService.get(mockedUnverifiedOrgDomainResponse.id)).toEqual(
|
||||
mockedUnverifiedOrgDomainResponse
|
||||
mockedUnverifiedOrgDomainResponse,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -116,7 +116,7 @@ describe("Org Domain Service", () => {
|
||||
orgDomainService.upsert([changedOrgDomain]);
|
||||
|
||||
expect(orgDomainService.get(mockedVerifiedOrgDomainResponse.id).domainName).toEqual(
|
||||
changedOrgDomain.domainName
|
||||
changedOrgDomain.domainName,
|
||||
);
|
||||
|
||||
const newOrgDomain = new OrganizationDomainResponse({
|
||||
|
||||
@@ -12,7 +12,7 @@ export class OrgDomainService implements OrgDomainInternalServiceAbstraction {
|
||||
|
||||
constructor(
|
||||
private platformUtilsService: PlatformUtilsService,
|
||||
private i18nService: I18nService
|
||||
private i18nService: I18nService,
|
||||
) {}
|
||||
|
||||
get(orgDomainId: string): OrganizationDomainResponse {
|
||||
@@ -26,7 +26,7 @@ export class OrgDomainService implements OrgDomainInternalServiceAbstraction {
|
||||
this.platformUtilsService.showToast(
|
||||
"success",
|
||||
null,
|
||||
this.i18nService.t("valueCopied", this.i18nService.t("dnsTxtRecord"))
|
||||
this.i18nService.t("valueCopied", this.i18nService.t("dnsTxtRecord")),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ export class OrgDomainService implements OrgDomainInternalServiceAbstraction {
|
||||
orgDomains.forEach((orgDomain: OrganizationDomainResponse) => {
|
||||
// Determine if passed in orgDomain exists in existing array:
|
||||
const index = existingOrgDomains.findIndex(
|
||||
(existingOrgDomain) => existingOrgDomain.id === orgDomain.id
|
||||
(existingOrgDomain) => existingOrgDomain.id === orgDomain.id,
|
||||
);
|
||||
if (index !== -1) {
|
||||
existingOrgDomains[index] = orgDomain;
|
||||
@@ -61,7 +61,7 @@ export class OrgDomainService implements OrgDomainInternalServiceAbstraction {
|
||||
|
||||
orgDomainIds.forEach((orgDomainId: string) => {
|
||||
const index = existingOrgDomains.findIndex(
|
||||
(existingOrgDomain) => existingOrgDomain.id === orgDomainId
|
||||
(existingOrgDomain) => existingOrgDomain.id === orgDomainId,
|
||||
);
|
||||
if (index !== -1) {
|
||||
existingOrgDomains.splice(index, 1);
|
||||
|
||||
@@ -30,7 +30,7 @@ export class OrganizationUserServiceImplementation implements OrganizationUserSe
|
||||
id: string,
|
||||
options?: {
|
||||
includeGroups?: boolean;
|
||||
}
|
||||
},
|
||||
): Promise<OrganizationUserDetailsResponse> {
|
||||
const params = new URLSearchParams();
|
||||
|
||||
@@ -43,7 +43,7 @@ export class OrganizationUserServiceImplementation implements OrganizationUserSe
|
||||
`/organizations/${organizationId}/users/${id}?${params.toString()}`,
|
||||
null,
|
||||
true,
|
||||
true
|
||||
true,
|
||||
);
|
||||
return new OrganizationUserDetailsResponse(r);
|
||||
}
|
||||
@@ -54,7 +54,7 @@ export class OrganizationUserServiceImplementation implements OrganizationUserSe
|
||||
"/organizations/" + organizationId + "/users/" + id + "/groups",
|
||||
null,
|
||||
true,
|
||||
true
|
||||
true,
|
||||
);
|
||||
return r;
|
||||
}
|
||||
@@ -64,7 +64,7 @@ export class OrganizationUserServiceImplementation implements OrganizationUserSe
|
||||
options?: {
|
||||
includeCollections?: boolean;
|
||||
includeGroups?: boolean;
|
||||
}
|
||||
},
|
||||
): Promise<ListResponse<OrganizationUserUserDetailsResponse>> {
|
||||
const params = new URLSearchParams();
|
||||
|
||||
@@ -80,35 +80,35 @@ export class OrganizationUserServiceImplementation implements OrganizationUserSe
|
||||
`/organizations/${organizationId}/users?${params.toString()}`,
|
||||
null,
|
||||
true,
|
||||
true
|
||||
true,
|
||||
);
|
||||
return new ListResponse(r, OrganizationUserUserDetailsResponse);
|
||||
}
|
||||
|
||||
async getOrganizationUserResetPasswordDetails(
|
||||
organizationId: string,
|
||||
id: string
|
||||
id: string,
|
||||
): Promise<OrganizationUserResetPasswordDetailsResponse> {
|
||||
const r = await this.apiService.send(
|
||||
"GET",
|
||||
"/organizations/" + organizationId + "/users/" + id + "/reset-password-details",
|
||||
null,
|
||||
true,
|
||||
true
|
||||
true,
|
||||
);
|
||||
return new OrganizationUserResetPasswordDetailsResponse(r);
|
||||
}
|
||||
|
||||
postOrganizationUserInvite(
|
||||
organizationId: string,
|
||||
request: OrganizationUserInviteRequest
|
||||
request: OrganizationUserInviteRequest,
|
||||
): Promise<void> {
|
||||
return this.apiService.send(
|
||||
"POST",
|
||||
"/organizations/" + organizationId + "/users/invite",
|
||||
request,
|
||||
true,
|
||||
false
|
||||
false,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -118,20 +118,20 @@ export class OrganizationUserServiceImplementation implements OrganizationUserSe
|
||||
"/organizations/" + organizationId + "/users/" + id + "/reinvite",
|
||||
null,
|
||||
true,
|
||||
false
|
||||
false,
|
||||
);
|
||||
}
|
||||
|
||||
async postManyOrganizationUserReinvite(
|
||||
organizationId: string,
|
||||
ids: string[]
|
||||
ids: string[],
|
||||
): Promise<ListResponse<OrganizationUserBulkResponse>> {
|
||||
const r = await this.apiService.send(
|
||||
"POST",
|
||||
"/organizations/" + organizationId + "/users/reinvite",
|
||||
new OrganizationUserBulkRequest(ids),
|
||||
true,
|
||||
true
|
||||
true,
|
||||
);
|
||||
return new ListResponse(r, OrganizationUserBulkResponse);
|
||||
}
|
||||
@@ -139,139 +139,139 @@ export class OrganizationUserServiceImplementation implements OrganizationUserSe
|
||||
postOrganizationUserAcceptInit(
|
||||
organizationId: string,
|
||||
id: string,
|
||||
request: OrganizationUserAcceptInitRequest
|
||||
request: OrganizationUserAcceptInitRequest,
|
||||
): Promise<void> {
|
||||
return this.apiService.send(
|
||||
"POST",
|
||||
"/organizations/" + organizationId + "/users/" + id + "/accept-init",
|
||||
request,
|
||||
true,
|
||||
false
|
||||
false,
|
||||
);
|
||||
}
|
||||
|
||||
postOrganizationUserAccept(
|
||||
organizationId: string,
|
||||
id: string,
|
||||
request: OrganizationUserAcceptRequest
|
||||
request: OrganizationUserAcceptRequest,
|
||||
): Promise<void> {
|
||||
return this.apiService.send(
|
||||
"POST",
|
||||
"/organizations/" + organizationId + "/users/" + id + "/accept",
|
||||
request,
|
||||
true,
|
||||
false
|
||||
false,
|
||||
);
|
||||
}
|
||||
|
||||
postOrganizationUserConfirm(
|
||||
organizationId: string,
|
||||
id: string,
|
||||
request: OrganizationUserConfirmRequest
|
||||
request: OrganizationUserConfirmRequest,
|
||||
): Promise<void> {
|
||||
return this.apiService.send(
|
||||
"POST",
|
||||
"/organizations/" + organizationId + "/users/" + id + "/confirm",
|
||||
request,
|
||||
true,
|
||||
false
|
||||
false,
|
||||
);
|
||||
}
|
||||
|
||||
async postOrganizationUsersPublicKey(
|
||||
organizationId: string,
|
||||
ids: string[]
|
||||
ids: string[],
|
||||
): Promise<ListResponse<OrganizationUserBulkPublicKeyResponse>> {
|
||||
const r = await this.apiService.send(
|
||||
"POST",
|
||||
"/organizations/" + organizationId + "/users/public-keys",
|
||||
new OrganizationUserBulkRequest(ids),
|
||||
true,
|
||||
true
|
||||
true,
|
||||
);
|
||||
return new ListResponse(r, OrganizationUserBulkPublicKeyResponse);
|
||||
}
|
||||
|
||||
async postOrganizationUserBulkConfirm(
|
||||
organizationId: string,
|
||||
request: OrganizationUserBulkConfirmRequest
|
||||
request: OrganizationUserBulkConfirmRequest,
|
||||
): Promise<ListResponse<OrganizationUserBulkResponse>> {
|
||||
const r = await this.apiService.send(
|
||||
"POST",
|
||||
"/organizations/" + organizationId + "/users/confirm",
|
||||
request,
|
||||
true,
|
||||
true
|
||||
true,
|
||||
);
|
||||
return new ListResponse(r, OrganizationUserBulkResponse);
|
||||
}
|
||||
|
||||
async putOrganizationUserBulkEnableSecretsManager(
|
||||
organizationId: string,
|
||||
ids: string[]
|
||||
ids: string[],
|
||||
): Promise<void> {
|
||||
await this.apiService.send(
|
||||
"PUT",
|
||||
"/organizations/" + organizationId + "/users/enable-secrets-manager",
|
||||
new OrganizationUserBulkRequest(ids),
|
||||
true,
|
||||
false
|
||||
false,
|
||||
);
|
||||
}
|
||||
|
||||
putOrganizationUser(
|
||||
organizationId: string,
|
||||
id: string,
|
||||
request: OrganizationUserUpdateRequest
|
||||
request: OrganizationUserUpdateRequest,
|
||||
): Promise<void> {
|
||||
return this.apiService.send(
|
||||
"PUT",
|
||||
"/organizations/" + organizationId + "/users/" + id,
|
||||
request,
|
||||
true,
|
||||
false
|
||||
false,
|
||||
);
|
||||
}
|
||||
|
||||
putOrganizationUserGroups(
|
||||
organizationId: string,
|
||||
id: string,
|
||||
request: OrganizationUserUpdateGroupsRequest
|
||||
request: OrganizationUserUpdateGroupsRequest,
|
||||
): Promise<void> {
|
||||
return this.apiService.send(
|
||||
"PUT",
|
||||
"/organizations/" + organizationId + "/users/" + id + "/groups",
|
||||
request,
|
||||
true,
|
||||
false
|
||||
false,
|
||||
);
|
||||
}
|
||||
|
||||
putOrganizationUserResetPasswordEnrollment(
|
||||
organizationId: string,
|
||||
userId: string,
|
||||
request: OrganizationUserResetPasswordEnrollmentRequest
|
||||
request: OrganizationUserResetPasswordEnrollmentRequest,
|
||||
): Promise<void> {
|
||||
return this.apiService.send(
|
||||
"PUT",
|
||||
"/organizations/" + organizationId + "/users/" + userId + "/reset-password-enrollment",
|
||||
request,
|
||||
true,
|
||||
false
|
||||
false,
|
||||
);
|
||||
}
|
||||
|
||||
putOrganizationUserResetPassword(
|
||||
organizationId: string,
|
||||
id: string,
|
||||
request: OrganizationUserResetPasswordRequest
|
||||
request: OrganizationUserResetPasswordRequest,
|
||||
): Promise<void> {
|
||||
return this.apiService.send(
|
||||
"PUT",
|
||||
"/organizations/" + organizationId + "/users/" + id + "/reset-password",
|
||||
request,
|
||||
true,
|
||||
false
|
||||
false,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -281,20 +281,20 @@ export class OrganizationUserServiceImplementation implements OrganizationUserSe
|
||||
"/organizations/" + organizationId + "/users/" + id,
|
||||
null,
|
||||
true,
|
||||
false
|
||||
false,
|
||||
);
|
||||
}
|
||||
|
||||
async deleteManyOrganizationUsers(
|
||||
organizationId: string,
|
||||
ids: string[]
|
||||
ids: string[],
|
||||
): Promise<ListResponse<OrganizationUserBulkResponse>> {
|
||||
const r = await this.apiService.send(
|
||||
"DELETE",
|
||||
"/organizations/" + organizationId + "/users",
|
||||
new OrganizationUserBulkRequest(ids),
|
||||
true,
|
||||
true
|
||||
true,
|
||||
);
|
||||
return new ListResponse(r, OrganizationUserBulkResponse);
|
||||
}
|
||||
@@ -305,20 +305,20 @@ export class OrganizationUserServiceImplementation implements OrganizationUserSe
|
||||
"/organizations/" + organizationId + "/users/" + id + "/revoke",
|
||||
null,
|
||||
true,
|
||||
false
|
||||
false,
|
||||
);
|
||||
}
|
||||
|
||||
async revokeManyOrganizationUsers(
|
||||
organizationId: string,
|
||||
ids: string[]
|
||||
ids: string[],
|
||||
): Promise<ListResponse<OrganizationUserBulkResponse>> {
|
||||
const r = await this.apiService.send(
|
||||
"PUT",
|
||||
"/organizations/" + organizationId + "/users/revoke",
|
||||
new OrganizationUserBulkRequest(ids),
|
||||
true,
|
||||
true
|
||||
true,
|
||||
);
|
||||
return new ListResponse(r, OrganizationUserBulkResponse);
|
||||
}
|
||||
@@ -329,20 +329,20 @@ export class OrganizationUserServiceImplementation implements OrganizationUserSe
|
||||
"/organizations/" + organizationId + "/users/" + id + "/restore",
|
||||
null,
|
||||
true,
|
||||
false
|
||||
false,
|
||||
);
|
||||
}
|
||||
|
||||
async restoreManyOrganizationUsers(
|
||||
organizationId: string,
|
||||
ids: string[]
|
||||
ids: string[],
|
||||
): Promise<ListResponse<OrganizationUserBulkResponse>> {
|
||||
const r = await this.apiService.send(
|
||||
"PUT",
|
||||
"/organizations/" + organizationId + "/users/restore",
|
||||
new OrganizationUserBulkRequest(ids),
|
||||
true,
|
||||
true
|
||||
true,
|
||||
);
|
||||
return new ListResponse(r, OrganizationUserBulkResponse);
|
||||
}
|
||||
|
||||
@@ -33,7 +33,10 @@ import { OrganizationResponse } from "../../models/response/organization.respons
|
||||
import { ProfileOrganizationResponse } from "../../models/response/profile-organization.response";
|
||||
|
||||
export class OrganizationApiService implements OrganizationApiServiceAbstraction {
|
||||
constructor(private apiService: ApiService, private syncService: SyncService) {}
|
||||
constructor(
|
||||
private apiService: ApiService,
|
||||
private syncService: SyncService,
|
||||
) {}
|
||||
|
||||
async get(id: string): Promise<OrganizationResponse> {
|
||||
const r = await this.apiService.send("GET", "/organizations/" + id, null, true, true);
|
||||
@@ -46,7 +49,7 @@ export class OrganizationApiService implements OrganizationApiServiceAbstraction
|
||||
"/organizations/" + id + "/billing",
|
||||
null,
|
||||
true,
|
||||
true
|
||||
true,
|
||||
);
|
||||
return new BillingResponse(r);
|
||||
}
|
||||
@@ -57,7 +60,7 @@ export class OrganizationApiService implements OrganizationApiServiceAbstraction
|
||||
"/organizations/" + id + "/subscription",
|
||||
null,
|
||||
true,
|
||||
true
|
||||
true,
|
||||
);
|
||||
return new OrganizationSubscriptionResponse(r);
|
||||
}
|
||||
@@ -68,7 +71,7 @@ export class OrganizationApiService implements OrganizationApiServiceAbstraction
|
||||
"/organizations/" + id + "/license?installationId=" + installationId,
|
||||
null,
|
||||
true,
|
||||
true
|
||||
true,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -78,7 +81,7 @@ export class OrganizationApiService implements OrganizationApiServiceAbstraction
|
||||
"/organizations/" + identifier + "/auto-enroll-status",
|
||||
null,
|
||||
true,
|
||||
true
|
||||
true,
|
||||
);
|
||||
return new OrganizationAutoEnrollStatusResponse(r);
|
||||
}
|
||||
@@ -96,7 +99,7 @@ export class OrganizationApiService implements OrganizationApiServiceAbstraction
|
||||
"/organizations/licenses/self-hosted",
|
||||
data,
|
||||
true,
|
||||
true
|
||||
true,
|
||||
);
|
||||
return new OrganizationResponse(r);
|
||||
}
|
||||
@@ -118,34 +121,34 @@ export class OrganizationApiService implements OrganizationApiServiceAbstraction
|
||||
"/organizations/" + id + "/upgrade",
|
||||
request,
|
||||
true,
|
||||
true
|
||||
true,
|
||||
);
|
||||
return new PaymentResponse(r);
|
||||
}
|
||||
|
||||
async updatePasswordManagerSeats(
|
||||
id: string,
|
||||
request: OrganizationSubscriptionUpdateRequest
|
||||
request: OrganizationSubscriptionUpdateRequest,
|
||||
): Promise<void> {
|
||||
return this.apiService.send(
|
||||
"POST",
|
||||
"/organizations/" + id + "/subscription",
|
||||
request,
|
||||
true,
|
||||
false
|
||||
false,
|
||||
);
|
||||
}
|
||||
|
||||
async updateSecretsManagerSubscription(
|
||||
id: string,
|
||||
request: OrganizationSmSubscriptionUpdateRequest
|
||||
request: OrganizationSmSubscriptionUpdateRequest,
|
||||
): Promise<void> {
|
||||
return this.apiService.send(
|
||||
"POST",
|
||||
"/organizations/" + id + "/sm-subscription",
|
||||
request,
|
||||
true,
|
||||
false
|
||||
false,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -155,7 +158,7 @@ export class OrganizationApiService implements OrganizationApiServiceAbstraction
|
||||
"/organizations/" + id + "/seat",
|
||||
request,
|
||||
true,
|
||||
true
|
||||
true,
|
||||
);
|
||||
return new PaymentResponse(r);
|
||||
}
|
||||
@@ -166,7 +169,7 @@ export class OrganizationApiService implements OrganizationApiServiceAbstraction
|
||||
"/organizations/" + id + "/storage",
|
||||
request,
|
||||
true,
|
||||
true
|
||||
true,
|
||||
);
|
||||
return new PaymentResponse(r);
|
||||
}
|
||||
@@ -177,7 +180,7 @@ export class OrganizationApiService implements OrganizationApiServiceAbstraction
|
||||
"/organizations/" + id + "/verify-bank",
|
||||
request,
|
||||
true,
|
||||
false
|
||||
false,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -205,7 +208,7 @@ export class OrganizationApiService implements OrganizationApiServiceAbstraction
|
||||
"/organizations/licenses/self-hosted/" + id,
|
||||
data,
|
||||
true,
|
||||
false
|
||||
false,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -215,7 +218,7 @@ export class OrganizationApiService implements OrganizationApiServiceAbstraction
|
||||
"/organizations/" + organizationId + "/import",
|
||||
request,
|
||||
true,
|
||||
false
|
||||
false,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -225,14 +228,14 @@ export class OrganizationApiService implements OrganizationApiServiceAbstraction
|
||||
"/organizations/" + id + "/api-key",
|
||||
request,
|
||||
true,
|
||||
true
|
||||
true,
|
||||
);
|
||||
return new ApiKeyResponse(r);
|
||||
}
|
||||
|
||||
async getApiKeyInformation(
|
||||
id: string,
|
||||
organizationApiKeyType: OrganizationApiKeyType = null
|
||||
organizationApiKeyType: OrganizationApiKeyType = null,
|
||||
): Promise<ListResponse<OrganizationApiKeyInformationResponse>> {
|
||||
const uri =
|
||||
organizationApiKeyType === null
|
||||
@@ -248,7 +251,7 @@ export class OrganizationApiService implements OrganizationApiServiceAbstraction
|
||||
"/organizations/" + id + "/rotate-api-key",
|
||||
request,
|
||||
true,
|
||||
true
|
||||
true,
|
||||
);
|
||||
return new ApiKeyResponse(r);
|
||||
}
|
||||
@@ -270,14 +273,14 @@ export class OrganizationApiService implements OrganizationApiServiceAbstraction
|
||||
|
||||
async updateKeys(
|
||||
id: string,
|
||||
request: OrganizationKeysRequest
|
||||
request: OrganizationKeysRequest,
|
||||
): Promise<OrganizationKeysResponse> {
|
||||
const r = await this.apiService.send(
|
||||
"POST",
|
||||
"/organizations/" + id + "/keys",
|
||||
request,
|
||||
true,
|
||||
true
|
||||
true,
|
||||
);
|
||||
// Not broadcasting anything because data on this response doesn't correspond to `Organization`
|
||||
return new OrganizationKeysResponse(r);
|
||||
@@ -294,7 +297,7 @@ export class OrganizationApiService implements OrganizationApiServiceAbstraction
|
||||
"/organizations/" + id + "/sso",
|
||||
request,
|
||||
true,
|
||||
true
|
||||
true,
|
||||
);
|
||||
// Not broadcasting anything because data on this response doesn't correspond to `Organization`
|
||||
return new OrganizationSsoResponse(r);
|
||||
@@ -306,34 +309,34 @@ export class OrganizationApiService implements OrganizationApiServiceAbstraction
|
||||
"/organizations/licenses/self-hosted/" + id + "/sync/",
|
||||
null,
|
||||
true,
|
||||
false
|
||||
false,
|
||||
);
|
||||
}
|
||||
|
||||
async subscribeToSecretsManager(
|
||||
id: string,
|
||||
request: SecretsManagerSubscribeRequest
|
||||
request: SecretsManagerSubscribeRequest,
|
||||
): Promise<ProfileOrganizationResponse> {
|
||||
const r = await this.apiService.send(
|
||||
"POST",
|
||||
"/organizations/" + id + "/subscribe-secrets-manager",
|
||||
request,
|
||||
true,
|
||||
true
|
||||
true,
|
||||
);
|
||||
return new ProfileOrganizationResponse(r);
|
||||
}
|
||||
|
||||
async updateCollectionManagement(
|
||||
id: string,
|
||||
request: OrganizationCollectionManagementUpdateRequest
|
||||
request: OrganizationCollectionManagementUpdateRequest,
|
||||
): Promise<OrganizationResponse> {
|
||||
const r = await this.apiService.send(
|
||||
"PUT",
|
||||
"/organizations/" + id + "/collection-management",
|
||||
request,
|
||||
true,
|
||||
true
|
||||
true,
|
||||
);
|
||||
const data = new OrganizationResponse(r);
|
||||
await this.syncService.fullSync(true);
|
||||
|
||||
@@ -14,7 +14,7 @@ describe("Organization Service", () => {
|
||||
let activeAccountUnlocked: BehaviorSubject<boolean>;
|
||||
|
||||
const resetStateService = async (
|
||||
customizeStateService: (stateService: MockProxy<StateService>) => void
|
||||
customizeStateService: (stateService: MockProxy<StateService>) => void,
|
||||
) => {
|
||||
mockClear(stateService);
|
||||
stateService = mock<StateService>();
|
||||
|
||||
@@ -25,7 +25,7 @@ export class OrganizationService implements InternalOrganizationServiceAbstracti
|
||||
|
||||
const data = await this.stateService.getOrganizations();
|
||||
this.updateObservables(data);
|
||||
})
|
||||
}),
|
||||
)
|
||||
.subscribe();
|
||||
}
|
||||
@@ -42,7 +42,7 @@ export class OrganizationService implements InternalOrganizationServiceAbstracti
|
||||
async canManageSponsorships(): Promise<boolean> {
|
||||
const organizations = this._organizations.getValue();
|
||||
return organizations.some(
|
||||
(o) => o.familySponsorshipAvailable || o.familySponsorshipFriendlyName !== null
|
||||
(o) => o.familySponsorshipAvailable || o.familySponsorshipFriendlyName !== null,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ export class PolicyApiService implements PolicyApiServiceAbstraction {
|
||||
constructor(
|
||||
private policyService: InternalPolicyService,
|
||||
private apiService: ApiService,
|
||||
private stateService: StateService
|
||||
private stateService: StateService,
|
||||
) {}
|
||||
|
||||
async getPolicy(organizationId: string, type: PolicyType): Promise<PolicyResponse> {
|
||||
@@ -27,7 +27,7 @@ export class PolicyApiService implements PolicyApiServiceAbstraction {
|
||||
"/organizations/" + organizationId + "/policies/" + type,
|
||||
null,
|
||||
true,
|
||||
true
|
||||
true,
|
||||
);
|
||||
return new PolicyResponse(r);
|
||||
}
|
||||
@@ -38,7 +38,7 @@ export class PolicyApiService implements PolicyApiServiceAbstraction {
|
||||
"/organizations/" + organizationId + "/policies",
|
||||
null,
|
||||
true,
|
||||
true
|
||||
true,
|
||||
);
|
||||
return new ListResponse(r, PolicyResponse);
|
||||
}
|
||||
@@ -47,7 +47,7 @@ export class PolicyApiService implements PolicyApiServiceAbstraction {
|
||||
organizationId: string,
|
||||
token: string,
|
||||
email: string,
|
||||
organizationUserId: string
|
||||
organizationUserId: string,
|
||||
): Promise<ListResponse<PolicyResponse>> {
|
||||
const r = await this.apiService.send(
|
||||
"GET",
|
||||
@@ -62,35 +62,34 @@ export class PolicyApiService implements PolicyApiServiceAbstraction {
|
||||
organizationUserId,
|
||||
null,
|
||||
false,
|
||||
true
|
||||
true,
|
||||
);
|
||||
return new ListResponse(r, PolicyResponse);
|
||||
}
|
||||
|
||||
private async getMasterPasswordPolicyResponseForOrgUser(
|
||||
organizationId: string
|
||||
organizationId: string,
|
||||
): Promise<PolicyResponse> {
|
||||
const response = await this.apiService.send(
|
||||
"GET",
|
||||
"/organizations/" + organizationId + "/policies/master-password",
|
||||
null,
|
||||
true,
|
||||
true
|
||||
true,
|
||||
);
|
||||
|
||||
return new PolicyResponse(response);
|
||||
}
|
||||
|
||||
async getMasterPasswordPolicyOptsForOrgUser(
|
||||
orgId: string
|
||||
orgId: string,
|
||||
): Promise<MasterPasswordPolicyOptions | null> {
|
||||
try {
|
||||
const masterPasswordPolicyResponse = await this.getMasterPasswordPolicyResponseForOrgUser(
|
||||
orgId
|
||||
);
|
||||
const masterPasswordPolicyResponse =
|
||||
await this.getMasterPasswordPolicyResponseForOrgUser(orgId);
|
||||
|
||||
const masterPasswordPolicy = this.policyService.mapPolicyFromResponse(
|
||||
masterPasswordPolicyResponse
|
||||
masterPasswordPolicyResponse,
|
||||
);
|
||||
|
||||
if (!masterPasswordPolicy) {
|
||||
@@ -98,7 +97,7 @@ export class PolicyApiService implements PolicyApiServiceAbstraction {
|
||||
}
|
||||
|
||||
return await firstValueFrom(
|
||||
this.policyService.masterPasswordPolicyOptions$([masterPasswordPolicy])
|
||||
this.policyService.masterPasswordPolicyOptions$([masterPasswordPolicy]),
|
||||
);
|
||||
} catch (error) {
|
||||
// If policy not found, return null
|
||||
@@ -116,7 +115,7 @@ export class PolicyApiService implements PolicyApiServiceAbstraction {
|
||||
"/organizations/" + organizationId + "/policies/" + type,
|
||||
request,
|
||||
true,
|
||||
true
|
||||
true,
|
||||
);
|
||||
const response = new PolicyResponse(r);
|
||||
const data = new PolicyData(response);
|
||||
|
||||
@@ -20,7 +20,7 @@ export class PolicyService implements InternalPolicyServiceAbstraction {
|
||||
|
||||
constructor(
|
||||
protected stateService: StateService,
|
||||
private organizationService: OrganizationService
|
||||
private organizationService: OrganizationService,
|
||||
) {
|
||||
this.stateService.activeAccountUnlocked$
|
||||
.pipe(
|
||||
@@ -37,7 +37,7 @@ export class PolicyService implements InternalPolicyServiceAbstraction {
|
||||
const data = await this.stateService.getEncryptedPolicies();
|
||||
|
||||
await this.updateObservables(data);
|
||||
})
|
||||
}),
|
||||
)
|
||||
.subscribe();
|
||||
}
|
||||
@@ -50,12 +50,12 @@ export class PolicyService implements InternalPolicyServiceAbstraction {
|
||||
policies,
|
||||
policyType,
|
||||
policyFilter,
|
||||
userId
|
||||
userId,
|
||||
);
|
||||
if (appliesToCurrentUser) {
|
||||
return policies.find((policy) => policy.type === policyType && policy.enabled);
|
||||
}
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ export class PolicyService implements InternalPolicyServiceAbstraction {
|
||||
});
|
||||
|
||||
return enforcedOptions;
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -145,14 +145,14 @@ export class PolicyService implements InternalPolicyServiceAbstraction {
|
||||
concatMap(async (policies) => {
|
||||
const userId = await this.stateService.getUserId();
|
||||
return await this.checkPoliciesThatApplyToUser(policies, policyType, policyFilter, userId);
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
evaluateMasterPassword(
|
||||
passwordStrength: number,
|
||||
newPassword: string,
|
||||
enforcedPolicyOptions: MasterPasswordPolicyOptions
|
||||
enforcedPolicyOptions: MasterPasswordPolicyOptions,
|
||||
): boolean {
|
||||
if (enforcedPolicyOptions == null) {
|
||||
return true;
|
||||
@@ -194,7 +194,7 @@ export class PolicyService implements InternalPolicyServiceAbstraction {
|
||||
|
||||
getResetPasswordPolicyOptions(
|
||||
policies: Policy[],
|
||||
orgId: string
|
||||
orgId: string,
|
||||
): [ResetPasswordPolicyOptions, boolean] {
|
||||
const resetPasswordPolicyOptions = new ResetPasswordPolicyOptions();
|
||||
|
||||
@@ -203,7 +203,7 @@ export class PolicyService implements InternalPolicyServiceAbstraction {
|
||||
}
|
||||
|
||||
const policy = policies.find(
|
||||
(p) => p.organizationId === orgId && p.type === PolicyType.ResetPassword && p.enabled
|
||||
(p) => p.organizationId === orgId && p.type === PolicyType.ResetPassword && p.enabled,
|
||||
);
|
||||
resetPasswordPolicyOptions.autoEnrollEnabled = policy?.data?.autoEnrollEnabled ?? false;
|
||||
|
||||
@@ -226,7 +226,7 @@ export class PolicyService implements InternalPolicyServiceAbstraction {
|
||||
async policyAppliesToUser(
|
||||
policyType: PolicyType,
|
||||
policyFilter?: (policy: Policy) => boolean,
|
||||
userId?: string
|
||||
userId?: string,
|
||||
) {
|
||||
const policies = await this.getAll(policyType, userId);
|
||||
|
||||
@@ -278,11 +278,11 @@ export class PolicyService implements InternalPolicyServiceAbstraction {
|
||||
policies: Policy[],
|
||||
policyType: PolicyType,
|
||||
policyFilter?: (policy: Policy) => boolean,
|
||||
userId?: string
|
||||
userId?: string,
|
||||
) {
|
||||
const organizations = await this.organizationService.getAll(userId);
|
||||
const filteredPolicies = policies.filter(
|
||||
(p) => p.type === policyType && p.enabled && (policyFilter == null || policyFilter(p))
|
||||
(p) => p.type === policyType && p.enabled && (policyFilter == null || policyFilter(p)),
|
||||
);
|
||||
const policySet = new Set(filteredPolicies.map((p) => p.organizationId));
|
||||
|
||||
@@ -291,7 +291,7 @@ export class PolicyService implements InternalPolicyServiceAbstraction {
|
||||
o.status >= OrganizationUserStatusType.Accepted &&
|
||||
o.usePolicies &&
|
||||
policySet.has(o.id) &&
|
||||
!this.isExemptFromPolicies(o, policyType)
|
||||
!this.isExemptFromPolicies(o, policyType),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,21 +4,21 @@ import { AuthRequestResponse } from "../models/response/auth-request.response";
|
||||
export abstract class AuthRequestCryptoServiceAbstraction {
|
||||
setUserKeyAfterDecryptingSharedUserKey: (
|
||||
authReqResponse: AuthRequestResponse,
|
||||
authReqPrivateKey: ArrayBuffer
|
||||
authReqPrivateKey: ArrayBuffer,
|
||||
) => Promise<void>;
|
||||
setKeysAfterDecryptingSharedMasterKeyAndHash: (
|
||||
authReqResponse: AuthRequestResponse,
|
||||
authReqPrivateKey: ArrayBuffer
|
||||
authReqPrivateKey: ArrayBuffer,
|
||||
) => Promise<void>;
|
||||
|
||||
decryptPubKeyEncryptedUserKey: (
|
||||
pubKeyEncryptedUserKey: string,
|
||||
privateKey: ArrayBuffer
|
||||
privateKey: ArrayBuffer,
|
||||
) => Promise<UserKey>;
|
||||
|
||||
decryptPubKeyEncryptedMasterKeyAndHash: (
|
||||
pubKeyEncryptedMasterKey: string,
|
||||
pubKeyEncryptedMasterKeyHash: string,
|
||||
privateKey: ArrayBuffer
|
||||
privateKey: ArrayBuffer,
|
||||
) => Promise<{ masterKey: MasterKey; masterKeyHash: string }>;
|
||||
}
|
||||
|
||||
@@ -27,11 +27,11 @@ export abstract class AuthService {
|
||||
| PasswordLoginCredentials
|
||||
| SsoLoginCredentials
|
||||
| AuthRequestLoginCredentials
|
||||
| WebAuthnLoginCredentials
|
||||
| WebAuthnLoginCredentials,
|
||||
) => Promise<AuthResult>;
|
||||
logInTwoFactor: (
|
||||
twoFactor: TokenTwoFactorRequest,
|
||||
captchaResponse: string
|
||||
captchaResponse: string,
|
||||
) => Promise<AuthResult>;
|
||||
logOut: (callback: () => void) => void;
|
||||
makePreloginKey: (masterPassword: string, email: string) => Promise<MasterKey>;
|
||||
@@ -44,7 +44,7 @@ export abstract class AuthService {
|
||||
passwordlessLogin: (
|
||||
id: string,
|
||||
key: string,
|
||||
requestApproved: boolean
|
||||
requestApproved: boolean,
|
||||
) => Promise<AuthRequestResponse>;
|
||||
getPushNotificationObs$: () => Observable<any>;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ export abstract class DeviceTrustCryptoServiceAbstraction {
|
||||
decryptUserKeyWithDeviceKey: (
|
||||
encryptedDevicePrivateKey: EncString,
|
||||
encryptedUserKey: EncString,
|
||||
deviceKey?: DeviceKey
|
||||
deviceKey?: DeviceKey,
|
||||
) => Promise<UserKey | null>;
|
||||
rotateDevicesTrust: (newUserKey: UserKey, masterPasswordHash: string) => Promise<void>;
|
||||
|
||||
|
||||
@@ -15,13 +15,13 @@ export abstract class DevicesApiServiceAbstraction {
|
||||
deviceIdentifier: string,
|
||||
devicePublicKeyEncryptedUserKey: string,
|
||||
userKeyEncryptedDevicePublicKey: string,
|
||||
deviceKeyEncryptedDevicePrivateKey: string
|
||||
deviceKeyEncryptedDevicePrivateKey: string,
|
||||
) => Promise<DeviceResponse>;
|
||||
|
||||
updateTrust: (updateDevicesTrustRequestModel: UpdateDevicesTrustRequest) => Promise<void>;
|
||||
|
||||
getDeviceKeys: (
|
||||
deviceIdentifier: string,
|
||||
secretVerificationRequest: SecretVerificationRequest
|
||||
secretVerificationRequest: SecretVerificationRequest,
|
||||
) => Promise<ProtectedDeviceResponse>;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,6 @@ export abstract class DevicesServiceAbstraction {
|
||||
deviceIdentifier: string,
|
||||
devicePublicKeyEncryptedUserKey: string,
|
||||
userKeyEncryptedDevicePublicKey: string,
|
||||
deviceKeyEncryptedDevicePrivateKey: string
|
||||
deviceKeyEncryptedDevicePrivateKey: string,
|
||||
) => Observable<DeviceView>;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ export abstract class KeyConnectorService {
|
||||
userNeedsMigration: () => Promise<boolean>;
|
||||
convertNewSsoUserToKeyConnector: (
|
||||
tokenResponse: IdentityTokenResponse,
|
||||
orgId: string
|
||||
orgId: string,
|
||||
) => Promise<void>;
|
||||
setUsesKeyConnector: (enabled: boolean) => Promise<void>;
|
||||
setConvertAccountRequired: (status: boolean) => Promise<void>;
|
||||
|
||||
@@ -4,7 +4,7 @@ export abstract class TokenService {
|
||||
setTokens: (
|
||||
accessToken: string,
|
||||
refreshToken: string,
|
||||
clientIdClientSecret: [string, string]
|
||||
clientIdClientSecret: [string, string],
|
||||
) => Promise<any>;
|
||||
setToken: (token: string) => Promise<any>;
|
||||
getToken: () => Promise<string>;
|
||||
|
||||
@@ -5,7 +5,7 @@ export abstract class UserVerificationService {
|
||||
buildRequest: <T extends SecretVerificationRequest>(
|
||||
verification: Verification,
|
||||
requestClass?: new () => T,
|
||||
alreadyHashed?: boolean
|
||||
alreadyHashed?: boolean,
|
||||
) => Promise<T>;
|
||||
verifyUser: (verification: Verification) => Promise<boolean>;
|
||||
requestOTP: () => Promise<void>;
|
||||
|
||||
@@ -33,7 +33,7 @@ export abstract class WebAuthnLoginServiceAbstraction {
|
||||
* If the assertion is not successfully obtained, it returns undefined.
|
||||
*/
|
||||
assertCredential: (
|
||||
credentialAssertionOptions: WebAuthnLoginCredentialAssertionOptionsView
|
||||
credentialAssertionOptions: WebAuthnLoginCredentialAssertionOptionsView,
|
||||
) => Promise<WebAuthnLoginCredentialAssertionView | undefined>;
|
||||
|
||||
/**
|
||||
|
||||
@@ -9,7 +9,7 @@ export class CaptchaIFrame extends IFrameComponent {
|
||||
private i18nService: I18nService,
|
||||
successCallback: (message: string) => any,
|
||||
errorCallback: (message: string) => any,
|
||||
infoCallback: (message: string) => any
|
||||
infoCallback: (message: string) => any,
|
||||
) {
|
||||
super(
|
||||
win,
|
||||
@@ -26,13 +26,13 @@ export class CaptchaIFrame extends IFrameComponent {
|
||||
} else {
|
||||
infoCallback(parsedMessage);
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
init(siteKey: string): void {
|
||||
super.initComponent(
|
||||
this.createParams({ siteKey: siteKey, locale: this.i18nService.translationLocale }, 1)
|
||||
this.createParams({ siteKey: siteKey, locale: this.i18nService.translationLocale }, 1),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ export abstract class IFrameComponent {
|
||||
private iframeId: string,
|
||||
public successCallback?: (message: string) => any,
|
||||
public errorCallback?: (message: string) => any,
|
||||
public infoCallback?: (message: string) => any
|
||||
public infoCallback?: (message: string) => any,
|
||||
) {
|
||||
this.connectorLink = win.document.createElement("a");
|
||||
}
|
||||
@@ -35,7 +35,7 @@ export abstract class IFrameComponent {
|
||||
return btoa(
|
||||
encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, (match, p1) => {
|
||||
return String.fromCharCode(("0x" + p1) as any);
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ describe("AuthRequestLoginStrategy", () => {
|
||||
const accessCode = "ACCESS_CODE";
|
||||
const authRequestId = "AUTH_REQUEST_ID";
|
||||
const decMasterKey = new SymmetricCryptoKey(
|
||||
new Uint8Array(64).buffer as CsprngArray
|
||||
new Uint8Array(64).buffer as CsprngArray,
|
||||
) as MasterKey;
|
||||
const decUserKey = new SymmetricCryptoKey(new Uint8Array(64).buffer as CsprngArray) as UserKey;
|
||||
const decMasterKeyHash = "LOCAL_PASSWORD_HASH";
|
||||
@@ -76,7 +76,7 @@ describe("AuthRequestLoginStrategy", () => {
|
||||
logService,
|
||||
stateService,
|
||||
twoFactorService,
|
||||
deviceTrustCryptoService
|
||||
deviceTrustCryptoService,
|
||||
);
|
||||
|
||||
tokenResponse = identityTokenResponseFactory();
|
||||
@@ -90,7 +90,7 @@ describe("AuthRequestLoginStrategy", () => {
|
||||
authRequestId,
|
||||
null,
|
||||
decMasterKey,
|
||||
decMasterKeyHash
|
||||
decMasterKeyHash,
|
||||
);
|
||||
|
||||
const masterKey = new SymmetricCryptoKey(new Uint8Array(64).buffer as CsprngArray) as MasterKey;
|
||||
@@ -117,7 +117,7 @@ describe("AuthRequestLoginStrategy", () => {
|
||||
authRequestId,
|
||||
decUserKey, // Pass userKey
|
||||
null, // No masterKey
|
||||
null // No masterKeyHash
|
||||
null, // No masterKeyHash
|
||||
);
|
||||
|
||||
// Call logIn
|
||||
|
||||
@@ -42,7 +42,7 @@ export class AuthRequestLoginStrategy extends LoginStrategy {
|
||||
logService: LogService,
|
||||
stateService: StateService,
|
||||
twoFactorService: TwoFactorService,
|
||||
private deviceTrustCryptoService: DeviceTrustCryptoServiceAbstraction
|
||||
private deviceTrustCryptoService: DeviceTrustCryptoServiceAbstraction,
|
||||
) {
|
||||
super(
|
||||
cryptoService,
|
||||
@@ -53,7 +53,7 @@ export class AuthRequestLoginStrategy extends LoginStrategy {
|
||||
messagingService,
|
||||
logService,
|
||||
stateService,
|
||||
twoFactorService
|
||||
twoFactorService,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ export class AuthRequestLoginStrategy extends LoginStrategy {
|
||||
credentials.accessCode,
|
||||
null,
|
||||
await this.buildTwoFactor(credentials.twoFactor),
|
||||
await this.buildDeviceRequest()
|
||||
await this.buildDeviceRequest(),
|
||||
);
|
||||
|
||||
this.tokenRequest.setAuthRequestAccessCode(credentials.authRequestId);
|
||||
@@ -75,7 +75,7 @@ export class AuthRequestLoginStrategy extends LoginStrategy {
|
||||
|
||||
override async logInTwoFactor(
|
||||
twoFactor: TokenTwoFactorRequest,
|
||||
captchaResponse: string
|
||||
captchaResponse: string,
|
||||
): Promise<AuthResult> {
|
||||
this.tokenRequest.captchaResponse = captchaResponse ?? this.captchaBypassToken;
|
||||
return super.logInTwoFactor(twoFactor);
|
||||
@@ -115,7 +115,7 @@ export class AuthRequestLoginStrategy extends LoginStrategy {
|
||||
|
||||
protected override async setPrivateKey(response: IdentityTokenResponse): Promise<void> {
|
||||
await this.cryptoService.setPrivateKey(
|
||||
response.privateKey ?? (await this.createKeyPairForOldAccount())
|
||||
response.privateKey ?? (await this.createKeyPairForOldAccount()),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ const twoFactorRemember = true;
|
||||
|
||||
export function identityTokenResponseFactory(
|
||||
masterPasswordPolicyResponse: MasterPasswordPolicyResponse = null,
|
||||
userDecryptionOptions: IUserDecryptionOptionsServerResponse = null
|
||||
userDecryptionOptions: IUserDecryptionOptionsServerResponse = null,
|
||||
) {
|
||||
return new IdentityTokenResponse({
|
||||
ForcePasswordReset: false,
|
||||
@@ -143,7 +143,7 @@ describe("LoginStrategy", () => {
|
||||
twoFactorService,
|
||||
passwordStrengthService,
|
||||
policyService,
|
||||
authService
|
||||
authService,
|
||||
);
|
||||
credentials = new PasswordLoginCredentials(email, masterPassword);
|
||||
});
|
||||
@@ -156,10 +156,10 @@ describe("LoginStrategy", () => {
|
||||
|
||||
beforeEach(() => {
|
||||
userKey = new SymmetricCryptoKey(
|
||||
new Uint8Array(userKeyBytesLength).buffer as CsprngArray
|
||||
new Uint8Array(userKeyBytesLength).buffer as CsprngArray,
|
||||
) as UserKey;
|
||||
masterKey = new SymmetricCryptoKey(
|
||||
new Uint8Array(masterKeyBytesLength).buffer as CsprngArray
|
||||
new Uint8Array(masterKeyBytesLength).buffer as CsprngArray,
|
||||
) as MasterKey;
|
||||
});
|
||||
|
||||
@@ -191,7 +191,7 @@ describe("LoginStrategy", () => {
|
||||
},
|
||||
keys: new AccountKeys(),
|
||||
decryptionOptions: AccountDecryptionOptions.fromResponse(idTokenResponse),
|
||||
})
|
||||
}),
|
||||
);
|
||||
expect(messagingService.send).toHaveBeenCalledWith("loggedIn");
|
||||
});
|
||||
@@ -202,7 +202,7 @@ describe("LoginStrategy", () => {
|
||||
apiService.postIdentityToken.mockResolvedValue(idTokenResponse);
|
||||
|
||||
const deviceKey = new SymmetricCryptoKey(
|
||||
new Uint8Array(userKeyBytesLength).buffer as CsprngArray
|
||||
new Uint8Array(userKeyBytesLength).buffer as CsprngArray,
|
||||
) as DeviceKey;
|
||||
|
||||
stateService.getDeviceKey.mockResolvedValue(deviceKey);
|
||||
@@ -215,7 +215,7 @@ describe("LoginStrategy", () => {
|
||||
|
||||
// Assert
|
||||
expect(stateService.addAccount).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ keys: accountKeys })
|
||||
expect.objectContaining({ keys: accountKeys }),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -273,7 +273,7 @@ describe("LoginStrategy", () => {
|
||||
expect(cryptoService.setUserKey).toHaveBeenCalled();
|
||||
expect(cryptoService.makeKeyPair).toHaveBeenCalled();
|
||||
expect(cryptoService.setUserKey.mock.invocationCallOrder[0]).toBeLessThan(
|
||||
cryptoService.makeKeyPair.mock.invocationCallOrder[0]
|
||||
cryptoService.makeKeyPair.mock.invocationCallOrder[0],
|
||||
);
|
||||
|
||||
expect(apiService.postAccountKeys).toHaveBeenCalled();
|
||||
@@ -352,7 +352,7 @@ describe("LoginStrategy", () => {
|
||||
token: twoFactorToken,
|
||||
remember: false,
|
||||
} as TokenTwoFactorRequest,
|
||||
})
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -362,7 +362,7 @@ describe("LoginStrategy", () => {
|
||||
credentials.twoFactor = new TokenTwoFactorRequest(
|
||||
twoFactorProviderType,
|
||||
twoFactorToken,
|
||||
twoFactorRemember
|
||||
twoFactorRemember,
|
||||
);
|
||||
|
||||
await passwordLoginStrategy.logIn(credentials);
|
||||
@@ -374,7 +374,7 @@ describe("LoginStrategy", () => {
|
||||
token: twoFactorToken,
|
||||
remember: twoFactorRemember,
|
||||
} as TokenTwoFactorRequest,
|
||||
})
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -384,14 +384,14 @@ describe("LoginStrategy", () => {
|
||||
email,
|
||||
masterPasswordHash,
|
||||
null,
|
||||
null
|
||||
null,
|
||||
);
|
||||
|
||||
apiService.postIdentityToken.mockResolvedValue(identityTokenResponseFactory());
|
||||
|
||||
await passwordLoginStrategy.logInTwoFactor(
|
||||
new TokenTwoFactorRequest(twoFactorProviderType, twoFactorToken, twoFactorRemember),
|
||||
null
|
||||
null,
|
||||
);
|
||||
|
||||
expect(apiService.postIdentityToken).toHaveBeenCalledWith(
|
||||
@@ -401,7 +401,7 @@ describe("LoginStrategy", () => {
|
||||
token: twoFactorToken,
|
||||
remember: twoFactorRemember,
|
||||
} as TokenTwoFactorRequest,
|
||||
})
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -55,7 +55,7 @@ export abstract class LoginStrategy {
|
||||
protected messagingService: MessagingService,
|
||||
protected logService: LogService,
|
||||
protected stateService: StateService,
|
||||
protected twoFactorService: TwoFactorService
|
||||
protected twoFactorService: TwoFactorService,
|
||||
) {}
|
||||
|
||||
abstract logIn(
|
||||
@@ -64,12 +64,12 @@ export abstract class LoginStrategy {
|
||||
| PasswordLoginCredentials
|
||||
| SsoLoginCredentials
|
||||
| AuthRequestLoginCredentials
|
||||
| WebAuthnLoginCredentials
|
||||
| WebAuthnLoginCredentials,
|
||||
): Promise<AuthResult>;
|
||||
|
||||
async logInTwoFactor(
|
||||
twoFactor: TokenTwoFactorRequest,
|
||||
captchaResponse: string = null
|
||||
captchaResponse: string = null,
|
||||
): Promise<AuthResult> {
|
||||
this.tokenRequest.setTwoFactor(twoFactor);
|
||||
const [authResult] = await this.startLogIn();
|
||||
@@ -153,7 +153,7 @@ export abstract class LoginStrategy {
|
||||
keys: accountKeys,
|
||||
decryptionOptions: AccountDecryptionOptions.fromResponse(tokenResponse),
|
||||
adminAuthRequest: adminAuthRequest?.toJSON(),
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -39,8 +39,8 @@ const hashedPassword = "HASHED_PASSWORD";
|
||||
const localHashedPassword = "LOCAL_HASHED_PASSWORD";
|
||||
const masterKey = new SymmetricCryptoKey(
|
||||
Utils.fromB64ToArray(
|
||||
"N2KWjlLpfi5uHjv+YcfUKIpZ1l+W+6HRensmIqD+BFYBf6N/dvFpJfWwYnVBdgFCK2tJTAIMLhqzIQQEUmGFgg=="
|
||||
)
|
||||
"N2KWjlLpfi5uHjv+YcfUKIpZ1l+W+6HRensmIqD+BFYBf6N/dvFpJfWwYnVBdgFCK2tJTAIMLhqzIQQEUmGFgg==",
|
||||
),
|
||||
) as MasterKey;
|
||||
const deviceId = Utils.newGuid();
|
||||
const masterPasswordPolicy = new MasterPasswordPolicyResponse({
|
||||
@@ -106,7 +106,7 @@ describe("PasswordLoginStrategy", () => {
|
||||
twoFactorService,
|
||||
passwordStrengthService,
|
||||
policyService,
|
||||
authService
|
||||
authService,
|
||||
);
|
||||
credentials = new PasswordLoginCredentials(email, masterPassword);
|
||||
tokenResponse = identityTokenResponseFactory(masterPasswordPolicy);
|
||||
@@ -129,7 +129,7 @@ describe("PasswordLoginStrategy", () => {
|
||||
token: null,
|
||||
}),
|
||||
captchaResponse: undefined,
|
||||
})
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -175,7 +175,7 @@ describe("PasswordLoginStrategy", () => {
|
||||
|
||||
expect(policyService.evaluateMasterPassword).toHaveBeenCalled();
|
||||
expect(stateService.setForceSetPasswordReason).toHaveBeenCalledWith(
|
||||
ForceSetPasswordReason.WeakMasterPassword
|
||||
ForceSetPasswordReason.WeakMasterPassword,
|
||||
);
|
||||
expect(result.forcePasswordReset).toEqual(ForceSetPasswordReason.WeakMasterPassword);
|
||||
});
|
||||
@@ -198,7 +198,7 @@ describe("PasswordLoginStrategy", () => {
|
||||
|
||||
// Second login request succeeds
|
||||
apiService.postIdentityToken.mockResolvedValueOnce(
|
||||
identityTokenResponseFactory(masterPasswordPolicy)
|
||||
identityTokenResponseFactory(masterPasswordPolicy),
|
||||
);
|
||||
const secondResult = await passwordLoginStrategy.logInTwoFactor(
|
||||
{
|
||||
@@ -206,7 +206,7 @@ describe("PasswordLoginStrategy", () => {
|
||||
token: "123456",
|
||||
remember: false,
|
||||
},
|
||||
""
|
||||
"",
|
||||
);
|
||||
|
||||
// First login attempt should not save the force password reset options
|
||||
@@ -214,7 +214,7 @@ describe("PasswordLoginStrategy", () => {
|
||||
|
||||
// Second login attempt should save the force password reset options and return in result
|
||||
expect(stateService.setForceSetPasswordReason).toHaveBeenCalledWith(
|
||||
ForceSetPasswordReason.WeakMasterPassword
|
||||
ForceSetPasswordReason.WeakMasterPassword,
|
||||
);
|
||||
expect(secondResult.forcePasswordReset).toEqual(ForceSetPasswordReason.WeakMasterPassword);
|
||||
});
|
||||
|
||||
@@ -56,7 +56,7 @@ export class PasswordLoginStrategy extends LoginStrategy {
|
||||
twoFactorService: TwoFactorService,
|
||||
private passwordStrengthService: PasswordStrengthServiceAbstraction,
|
||||
private policyService: PolicyService,
|
||||
private authService: AuthService
|
||||
private authService: AuthService,
|
||||
) {
|
||||
super(
|
||||
cryptoService,
|
||||
@@ -67,13 +67,13 @@ export class PasswordLoginStrategy extends LoginStrategy {
|
||||
messagingService,
|
||||
logService,
|
||||
stateService,
|
||||
twoFactorService
|
||||
twoFactorService,
|
||||
);
|
||||
}
|
||||
|
||||
override async logInTwoFactor(
|
||||
twoFactor: TokenTwoFactorRequest,
|
||||
captchaResponse: string
|
||||
captchaResponse: string,
|
||||
): Promise<AuthResult> {
|
||||
this.tokenRequest.captchaResponse = captchaResponse ?? this.captchaBypassToken;
|
||||
const result = await super.logInTwoFactor(twoFactor);
|
||||
@@ -100,7 +100,7 @@ export class PasswordLoginStrategy extends LoginStrategy {
|
||||
this.localMasterKeyHash = await this.cryptoService.hashMasterKey(
|
||||
masterPassword,
|
||||
this.masterKey,
|
||||
HashPurpose.LocalAuthorization
|
||||
HashPurpose.LocalAuthorization,
|
||||
);
|
||||
const masterKeyHash = await this.cryptoService.hashMasterKey(masterPassword, this.masterKey);
|
||||
|
||||
@@ -109,7 +109,7 @@ export class PasswordLoginStrategy extends LoginStrategy {
|
||||
masterKeyHash,
|
||||
captchaToken,
|
||||
await this.buildTwoFactor(twoFactor),
|
||||
await this.buildDeviceRequest()
|
||||
await this.buildDeviceRequest(),
|
||||
);
|
||||
|
||||
const [authResult, identityResponse] = await this.startLogIn();
|
||||
@@ -122,7 +122,7 @@ export class PasswordLoginStrategy extends LoginStrategy {
|
||||
// If there is a policy active, evaluate the supplied password before its no longer in memory
|
||||
const meetsRequirements = this.evaluateMasterPassword(
|
||||
credentials,
|
||||
masterPasswordPolicyOptions
|
||||
masterPasswordPolicyOptions,
|
||||
);
|
||||
|
||||
if (!meetsRequirements) {
|
||||
@@ -132,7 +132,7 @@ export class PasswordLoginStrategy extends LoginStrategy {
|
||||
} else {
|
||||
// Authentication was successful, save the force update password options with the state service
|
||||
await this.stateService.setForceSetPasswordReason(
|
||||
ForceSetPasswordReason.WeakMasterPassword
|
||||
ForceSetPasswordReason.WeakMasterPassword,
|
||||
);
|
||||
authResult.forcePasswordReset = ForceSetPasswordReason.WeakMasterPassword;
|
||||
}
|
||||
@@ -162,7 +162,7 @@ export class PasswordLoginStrategy extends LoginStrategy {
|
||||
|
||||
protected override async setPrivateKey(response: IdentityTokenResponse): Promise<void> {
|
||||
await this.cryptoService.setPrivateKey(
|
||||
response.privateKey ?? (await this.createKeyPairForOldAccount())
|
||||
response.privateKey ?? (await this.createKeyPairForOldAccount()),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@ export class PasswordLoginStrategy extends LoginStrategy {
|
||||
}
|
||||
|
||||
private getMasterPasswordPolicyOptionsFromResponse(
|
||||
response: IdentityTokenResponse | IdentityTwoFactorResponse | IdentityCaptchaResponse
|
||||
response: IdentityTokenResponse | IdentityTwoFactorResponse | IdentityCaptchaResponse,
|
||||
): MasterPasswordPolicyOptions {
|
||||
if (response == null || response instanceof IdentityCaptchaResponse) {
|
||||
return null;
|
||||
@@ -181,12 +181,10 @@ export class PasswordLoginStrategy extends LoginStrategy {
|
||||
|
||||
private evaluateMasterPassword(
|
||||
{ masterPassword, email }: PasswordLoginCredentials,
|
||||
options: MasterPasswordPolicyOptions
|
||||
options: MasterPasswordPolicyOptions,
|
||||
): boolean {
|
||||
const passwordStrength = this.passwordStrengthService.getPasswordStrength(
|
||||
masterPassword,
|
||||
email
|
||||
)?.score;
|
||||
const passwordStrength = this.passwordStrengthService.getPasswordStrength(masterPassword, email)
|
||||
?.score;
|
||||
|
||||
return this.policyService.evaluateMasterPassword(passwordStrength, masterPassword, options);
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ describe("SsoLoginStrategy", () => {
|
||||
keyConnectorService,
|
||||
deviceTrustCryptoService,
|
||||
authRequestCryptoService,
|
||||
i18nService
|
||||
i18nService,
|
||||
);
|
||||
credentials = new SsoLoginCredentials(ssoCode, ssoCodeVerifier, ssoRedirectUrl, ssoOrgId);
|
||||
});
|
||||
@@ -111,7 +111,7 @@ describe("SsoLoginStrategy", () => {
|
||||
provider: null,
|
||||
token: null,
|
||||
}),
|
||||
})
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -185,7 +185,7 @@ describe("SsoLoginStrategy", () => {
|
||||
// Arrange
|
||||
const idTokenResponse: IdentityTokenResponse = identityTokenResponseFactory(
|
||||
null,
|
||||
userDecryptionOptsServerResponseWithTdeOption
|
||||
userDecryptionOptsServerResponseWithTdeOption,
|
||||
);
|
||||
|
||||
apiService.postIdentityToken.mockResolvedValue(idTokenResponse);
|
||||
@@ -208,7 +208,7 @@ describe("SsoLoginStrategy", () => {
|
||||
// Arrange
|
||||
const idTokenResponse: IdentityTokenResponse = identityTokenResponseFactory(
|
||||
null,
|
||||
userDecryptionOptsServerResponseWithTdeOption
|
||||
userDecryptionOptsServerResponseWithTdeOption,
|
||||
);
|
||||
apiService.postIdentityToken.mockResolvedValue(idTokenResponse);
|
||||
// Set deviceKey to be null
|
||||
@@ -248,7 +248,7 @@ describe("SsoLoginStrategy", () => {
|
||||
// Arrange
|
||||
const idTokenResponse: IdentityTokenResponse = identityTokenResponseFactory(
|
||||
null,
|
||||
userDecryptionOptsServerResponseWithTdeOption
|
||||
userDecryptionOptsServerResponseWithTdeOption,
|
||||
);
|
||||
apiService.postIdentityToken.mockResolvedValue(idTokenResponse);
|
||||
deviceTrustCryptoService.getDeviceKey.mockResolvedValue(mockDeviceKey);
|
||||
@@ -275,7 +275,7 @@ describe("SsoLoginStrategy", () => {
|
||||
|
||||
it("gets and sets the master key if Key Connector is enabled and the user doesn't have a master password", async () => {
|
||||
const masterKey = new SymmetricCryptoKey(
|
||||
new Uint8Array(64).buffer as CsprngArray
|
||||
new Uint8Array(64).buffer as CsprngArray,
|
||||
) as MasterKey;
|
||||
|
||||
apiService.postIdentityToken.mockResolvedValue(tokenResponse);
|
||||
@@ -295,14 +295,14 @@ describe("SsoLoginStrategy", () => {
|
||||
|
||||
expect(keyConnectorService.convertNewSsoUserToKeyConnector).toHaveBeenCalledWith(
|
||||
tokenResponse,
|
||||
ssoOrgId
|
||||
ssoOrgId,
|
||||
);
|
||||
});
|
||||
|
||||
it("decrypts and sets the user key if Key Connector is enabled and the user doesn't have a master password", async () => {
|
||||
const userKey = new SymmetricCryptoKey(new Uint8Array(64).buffer as CsprngArray) as UserKey;
|
||||
const masterKey = new SymmetricCryptoKey(
|
||||
new Uint8Array(64).buffer as CsprngArray
|
||||
new Uint8Array(64).buffer as CsprngArray,
|
||||
) as MasterKey;
|
||||
|
||||
apiService.postIdentityToken.mockResolvedValue(tokenResponse);
|
||||
@@ -326,7 +326,7 @@ describe("SsoLoginStrategy", () => {
|
||||
|
||||
it("gets and sets the master key if Key Connector is enabled and the user doesn't have a master password", async () => {
|
||||
const masterKey = new SymmetricCryptoKey(
|
||||
new Uint8Array(64).buffer as CsprngArray
|
||||
new Uint8Array(64).buffer as CsprngArray,
|
||||
) as MasterKey;
|
||||
|
||||
apiService.postIdentityToken.mockResolvedValue(tokenResponse);
|
||||
@@ -346,14 +346,14 @@ describe("SsoLoginStrategy", () => {
|
||||
|
||||
expect(keyConnectorService.convertNewSsoUserToKeyConnector).toHaveBeenCalledWith(
|
||||
tokenResponse,
|
||||
ssoOrgId
|
||||
ssoOrgId,
|
||||
);
|
||||
});
|
||||
|
||||
it("decrypts and sets the user key if Key Connector is enabled and the user doesn't have a master password", async () => {
|
||||
const userKey = new SymmetricCryptoKey(new Uint8Array(64).buffer as CsprngArray) as UserKey;
|
||||
const masterKey = new SymmetricCryptoKey(
|
||||
new Uint8Array(64).buffer as CsprngArray
|
||||
new Uint8Array(64).buffer as CsprngArray,
|
||||
) as MasterKey;
|
||||
|
||||
apiService.postIdentityToken.mockResolvedValue(tokenResponse);
|
||||
|
||||
@@ -44,7 +44,7 @@ export class SsoLoginStrategy extends LoginStrategy {
|
||||
private keyConnectorService: KeyConnectorService,
|
||||
private deviceTrustCryptoService: DeviceTrustCryptoServiceAbstraction,
|
||||
private authReqCryptoService: AuthRequestCryptoServiceAbstraction,
|
||||
private i18nService: I18nService
|
||||
private i18nService: I18nService,
|
||||
) {
|
||||
super(
|
||||
cryptoService,
|
||||
@@ -55,7 +55,7 @@ export class SsoLoginStrategy extends LoginStrategy {
|
||||
messagingService,
|
||||
logService,
|
||||
stateService,
|
||||
twoFactorService
|
||||
twoFactorService,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ export class SsoLoginStrategy extends LoginStrategy {
|
||||
credentials.codeVerifier,
|
||||
credentials.redirectUrl,
|
||||
await this.buildTwoFactor(credentials.twoFactor),
|
||||
await this.buildDeviceRequest()
|
||||
await this.buildDeviceRequest(),
|
||||
);
|
||||
|
||||
const [ssoAuthResult] = await this.startLogIn();
|
||||
@@ -200,14 +200,14 @@ export class SsoLoginStrategy extends LoginStrategy {
|
||||
if (adminAuthReqResponse.masterPasswordHash) {
|
||||
await this.authReqCryptoService.setKeysAfterDecryptingSharedMasterKeyAndHash(
|
||||
adminAuthReqResponse,
|
||||
adminAuthReqStorable.privateKey
|
||||
adminAuthReqStorable.privateKey,
|
||||
);
|
||||
} else {
|
||||
// if masterPasswordHash is null, we will always receive authReqResponse.key
|
||||
// as authRequestPublicKey(userKey)
|
||||
await this.authReqCryptoService.setUserKeyAfterDecryptingSharedUserKey(
|
||||
adminAuthReqResponse,
|
||||
adminAuthReqStorable.privateKey
|
||||
adminAuthReqStorable.privateKey,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -239,7 +239,7 @@ export class SsoLoginStrategy extends LoginStrategy {
|
||||
const userKey = await this.deviceTrustCryptoService.decryptUserKeyWithDeviceKey(
|
||||
encDevicePrivateKey,
|
||||
encUserKey,
|
||||
deviceKey
|
||||
deviceKey,
|
||||
);
|
||||
|
||||
if (userKey) {
|
||||
@@ -267,7 +267,7 @@ export class SsoLoginStrategy extends LoginStrategy {
|
||||
|
||||
if (!newSsoUser) {
|
||||
await this.cryptoService.setPrivateKey(
|
||||
tokenResponse.privateKey ?? (await this.createKeyPairForOldAccount())
|
||||
tokenResponse.privateKey ?? (await this.createKeyPairForOldAccount()),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ describe("UserApiLoginStrategy", () => {
|
||||
stateService,
|
||||
twoFactorService,
|
||||
environmentService,
|
||||
keyConnectorService
|
||||
keyConnectorService,
|
||||
);
|
||||
|
||||
credentials = new UserApiLoginCredentials(apiClientId, apiClientSecret);
|
||||
@@ -93,7 +93,7 @@ describe("UserApiLoginStrategy", () => {
|
||||
provider: null,
|
||||
token: null,
|
||||
}),
|
||||
})
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ export class UserApiLoginStrategy extends LoginStrategy {
|
||||
stateService: StateService,
|
||||
twoFactorService: TwoFactorService,
|
||||
private environmentService: EnvironmentService,
|
||||
private keyConnectorService: KeyConnectorService
|
||||
private keyConnectorService: KeyConnectorService,
|
||||
) {
|
||||
super(
|
||||
cryptoService,
|
||||
@@ -40,7 +40,7 @@ export class UserApiLoginStrategy extends LoginStrategy {
|
||||
messagingService,
|
||||
logService,
|
||||
stateService,
|
||||
twoFactorService
|
||||
twoFactorService,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ export class UserApiLoginStrategy extends LoginStrategy {
|
||||
credentials.clientId,
|
||||
credentials.clientSecret,
|
||||
await this.buildTwoFactor(),
|
||||
await this.buildDeviceRequest()
|
||||
await this.buildDeviceRequest(),
|
||||
);
|
||||
|
||||
const [authResult] = await this.startLogIn();
|
||||
@@ -77,7 +77,7 @@ export class UserApiLoginStrategy extends LoginStrategy {
|
||||
|
||||
protected override async setPrivateKey(response: IdentityTokenResponse): Promise<void> {
|
||||
await this.cryptoService.setPrivateKey(
|
||||
response.privateKey ?? (await this.createKeyPairForOldAccount())
|
||||
response.privateKey ?? (await this.createKeyPairForOldAccount()),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ describe("WebAuthnLoginStrategy", () => {
|
||||
messagingService,
|
||||
logService,
|
||||
stateService,
|
||||
twoFactorService
|
||||
twoFactorService,
|
||||
);
|
||||
|
||||
// Create credentials
|
||||
@@ -128,7 +128,7 @@ describe("WebAuthnLoginStrategy", () => {
|
||||
// Arrange
|
||||
const idTokenResponse: IdentityTokenResponse = identityTokenResponseFactory(
|
||||
null,
|
||||
userDecryptionOptsServerResponseWithWebAuthnPrfOption
|
||||
userDecryptionOptsServerResponseWithWebAuthnPrfOption,
|
||||
);
|
||||
|
||||
apiService.postIdentityToken.mockResolvedValue(idTokenResponse);
|
||||
@@ -146,7 +146,7 @@ describe("WebAuthnLoginStrategy", () => {
|
||||
device: expect.objectContaining({
|
||||
identifier: deviceId,
|
||||
}),
|
||||
})
|
||||
}),
|
||||
);
|
||||
|
||||
expect(authResult).toBeInstanceOf(AuthResult);
|
||||
@@ -164,7 +164,7 @@ describe("WebAuthnLoginStrategy", () => {
|
||||
// Arrange
|
||||
const idTokenResponse: IdentityTokenResponse = identityTokenResponseFactory(
|
||||
null,
|
||||
userDecryptionOptsServerResponseWithWebAuthnPrfOption
|
||||
userDecryptionOptsServerResponseWithWebAuthnPrfOption,
|
||||
);
|
||||
|
||||
apiService.postIdentityToken.mockResolvedValue(idTokenResponse);
|
||||
@@ -187,12 +187,12 @@ describe("WebAuthnLoginStrategy", () => {
|
||||
expect(cryptoService.decryptToBytes).toHaveBeenCalledTimes(1);
|
||||
expect(cryptoService.decryptToBytes).toHaveBeenCalledWith(
|
||||
idTokenResponse.userDecryptionOptions.webAuthnPrfOption.encryptedPrivateKey,
|
||||
webAuthnCredentials.prfKey
|
||||
webAuthnCredentials.prfKey,
|
||||
);
|
||||
expect(cryptoService.rsaDecrypt).toHaveBeenCalledTimes(1);
|
||||
expect(cryptoService.rsaDecrypt).toHaveBeenCalledWith(
|
||||
idTokenResponse.userDecryptionOptions.webAuthnPrfOption.encryptedUserKey.encryptedString,
|
||||
mockPrfPrivateKey
|
||||
mockPrfPrivateKey,
|
||||
);
|
||||
expect(cryptoService.setUserKey).toHaveBeenCalledWith(mockUserKey);
|
||||
expect(cryptoService.setPrivateKey).toHaveBeenCalledWith(idTokenResponse.privateKey);
|
||||
@@ -205,7 +205,7 @@ describe("WebAuthnLoginStrategy", () => {
|
||||
// Arrange
|
||||
const idTokenResponse: IdentityTokenResponse = identityTokenResponseFactory(
|
||||
null,
|
||||
userDecryptionOptsServerResponseWithWebAuthnPrfOption
|
||||
userDecryptionOptsServerResponseWithWebAuthnPrfOption,
|
||||
);
|
||||
|
||||
apiService.postIdentityToken.mockResolvedValue(idTokenResponse);
|
||||
@@ -247,7 +247,7 @@ describe("WebAuthnLoginStrategy", () => {
|
||||
// Arrange
|
||||
const idTokenResponse: IdentityTokenResponse = identityTokenResponseFactory(
|
||||
null,
|
||||
userDecryptionOptsServerResponseWithWebAuthnPrfOption
|
||||
userDecryptionOptsServerResponseWithWebAuthnPrfOption,
|
||||
);
|
||||
|
||||
apiService.postIdentityToken.mockResolvedValue(idTokenResponse);
|
||||
@@ -265,7 +265,7 @@ describe("WebAuthnLoginStrategy", () => {
|
||||
// Arrange
|
||||
const idTokenResponse: IdentityTokenResponse = identityTokenResponseFactory(
|
||||
null,
|
||||
userDecryptionOptsServerResponseWithWebAuthnPrfOption
|
||||
userDecryptionOptsServerResponseWithWebAuthnPrfOption,
|
||||
);
|
||||
|
||||
apiService.postIdentityToken.mockResolvedValue(idTokenResponse);
|
||||
@@ -314,7 +314,7 @@ class MockPublicKeyCredential implements PublicKeyCredential {
|
||||
// Creating the array buffer from a known hex value allows us to
|
||||
// assert on the value in tests
|
||||
private prfKeyArrayBuffer: ArrayBuffer = Utils.hexStringToArrayBuffer(
|
||||
"1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"
|
||||
"1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
|
||||
);
|
||||
|
||||
getClientExtensionResults(): any {
|
||||
|
||||
@@ -35,13 +35,13 @@ export class WebAuthnLoginStrategy extends LoginStrategy {
|
||||
// decrypt prf encrypted private key
|
||||
const privateKey = await this.cryptoService.decryptToBytes(
|
||||
webAuthnPrfOption.encryptedPrivateKey,
|
||||
this.credentials.prfKey
|
||||
this.credentials.prfKey,
|
||||
);
|
||||
|
||||
// decrypt user key with private key
|
||||
const userKey = await this.cryptoService.rsaDecrypt(
|
||||
webAuthnPrfOption.encryptedUserKey.encryptedString,
|
||||
privateKey
|
||||
privateKey,
|
||||
);
|
||||
|
||||
if (userKey) {
|
||||
@@ -52,7 +52,7 @@ export class WebAuthnLoginStrategy extends LoginStrategy {
|
||||
|
||||
protected override async setPrivateKey(response: IdentityTokenResponse): Promise<void> {
|
||||
await this.cryptoService.setPrivateKey(
|
||||
response.privateKey ?? (await this.createKeyPairForOldAccount())
|
||||
response.privateKey ?? (await this.createKeyPairForOldAccount()),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ export class WebAuthnLoginStrategy extends LoginStrategy {
|
||||
this.tokenRequest = new WebAuthnLoginTokenRequest(
|
||||
credentials.token,
|
||||
credentials.deviceResponse,
|
||||
await this.buildDeviceRequest()
|
||||
await this.buildDeviceRequest(),
|
||||
);
|
||||
|
||||
const [authResult] = await this.startLogIn();
|
||||
|
||||
@@ -127,10 +127,10 @@ export class SsoConfigApi extends BaseResponse {
|
||||
this.idpX509PublicCert = this.getResponseProperty("IdpX509PublicCert");
|
||||
this.idpOutboundSigningAlgorithm = this.getResponseProperty("IdpOutboundSigningAlgorithm");
|
||||
this.idpAllowUnsolicitedAuthnResponse = this.getResponseProperty(
|
||||
"IdpAllowUnsolicitedAuthnResponse"
|
||||
"IdpAllowUnsolicitedAuthnResponse",
|
||||
);
|
||||
this.idpDisableOutboundLogoutRequests = this.getResponseProperty(
|
||||
"IdpDisableOutboundLogoutRequests"
|
||||
"IdpDisableOutboundLogoutRequests",
|
||||
);
|
||||
this.idpWantAuthnRequestsSigned = this.getResponseProperty("IdpWantAuthnRequestsSigned");
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ export class PasswordLoginCredentials {
|
||||
public email: string,
|
||||
public masterPassword: string,
|
||||
public captchaToken?: string,
|
||||
public twoFactor?: TokenTwoFactorRequest
|
||||
public twoFactor?: TokenTwoFactorRequest,
|
||||
) {}
|
||||
}
|
||||
|
||||
@@ -26,14 +26,17 @@ export class SsoLoginCredentials {
|
||||
public codeVerifier: string,
|
||||
public redirectUrl: string,
|
||||
public orgId: string,
|
||||
public twoFactor?: TokenTwoFactorRequest
|
||||
public twoFactor?: TokenTwoFactorRequest,
|
||||
) {}
|
||||
}
|
||||
|
||||
export class UserApiLoginCredentials {
|
||||
readonly type = AuthenticationType.UserApi;
|
||||
|
||||
constructor(public clientId: string, public clientSecret: string) {}
|
||||
constructor(
|
||||
public clientId: string,
|
||||
public clientSecret: string,
|
||||
) {}
|
||||
}
|
||||
|
||||
export class AuthRequestLoginCredentials {
|
||||
@@ -46,7 +49,7 @@ export class AuthRequestLoginCredentials {
|
||||
public decryptedUserKey: UserKey,
|
||||
public decryptedMasterKey: MasterKey,
|
||||
public decryptedMasterKeyHash: string,
|
||||
public twoFactor?: TokenTwoFactorRequest
|
||||
public twoFactor?: TokenTwoFactorRequest,
|
||||
) {}
|
||||
}
|
||||
|
||||
@@ -56,6 +59,6 @@ export class WebAuthnLoginCredentials {
|
||||
constructor(
|
||||
public token: string,
|
||||
public deviceResponse: WebAuthnLoginAssertionResponseRequest,
|
||||
public prfKey?: SymmetricCryptoKey
|
||||
public prfKey?: SymmetricCryptoKey,
|
||||
) {}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,6 @@ export class TrustedDeviceUserDecryptionOption {
|
||||
constructor(
|
||||
public hasAdminApproval: boolean,
|
||||
public hasLoginApprovingDevice: boolean,
|
||||
public hasManageResetPasswordPermission: boolean
|
||||
public hasManageResetPasswordPermission: boolean,
|
||||
) {}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,6 @@ export class CreateAuthRequest {
|
||||
readonly deviceIdentifier: string,
|
||||
readonly publicKey: string,
|
||||
readonly type: AuthRequestType,
|
||||
readonly accessCode: string
|
||||
readonly accessCode: string,
|
||||
) {}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ export class PasswordTokenRequest extends TokenRequest implements CaptchaProtect
|
||||
public masterPasswordHash: string,
|
||||
public captchaResponse: string,
|
||||
protected twoFactor: TokenTwoFactorRequest,
|
||||
device?: DeviceRequest
|
||||
device?: DeviceRequest,
|
||||
) {
|
||||
super(twoFactor, device);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ export class SsoTokenRequest extends TokenRequest {
|
||||
public codeVerifier: string,
|
||||
public redirectUri: string,
|
||||
protected twoFactor: TokenTwoFactorRequest,
|
||||
device?: DeviceRequest
|
||||
device?: DeviceRequest,
|
||||
) {
|
||||
super(twoFactor, device);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,6 @@ export class TokenTwoFactorRequest {
|
||||
constructor(
|
||||
public provider: TwoFactorProviderType = null,
|
||||
public token: string = null,
|
||||
public remember: boolean = false
|
||||
public remember: boolean = false,
|
||||
) {}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,10 @@ export abstract class TokenRequest {
|
||||
protected device?: DeviceRequest;
|
||||
protected authRequest: string;
|
||||
|
||||
constructor(protected twoFactor?: TokenTwoFactorRequest, device?: DeviceRequest) {
|
||||
constructor(
|
||||
protected twoFactor?: TokenTwoFactorRequest,
|
||||
device?: DeviceRequest,
|
||||
) {
|
||||
this.device = device != null ? device : null;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ export class UserApiTokenRequest extends TokenRequest {
|
||||
public clientId: string,
|
||||
public clientSecret: string,
|
||||
protected twoFactor: TokenTwoFactorRequest,
|
||||
device?: DeviceRequest
|
||||
device?: DeviceRequest,
|
||||
) {
|
||||
super(twoFactor, device);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ export class WebAuthnLoginTokenRequest extends TokenRequest {
|
||||
constructor(
|
||||
public token: string,
|
||||
public deviceResponse: WebAuthnLoginAssertionResponseRequest,
|
||||
device?: DeviceRequest
|
||||
device?: DeviceRequest,
|
||||
) {
|
||||
super(undefined, device);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,6 @@ export class PasswordlessAuthRequest {
|
||||
readonly key: string,
|
||||
readonly masterPasswordHash: string,
|
||||
readonly deviceIdentifier: string,
|
||||
readonly requestApproved: boolean
|
||||
readonly requestApproved: boolean,
|
||||
) {}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ export class SetKeyConnectorKeyRequest {
|
||||
kdf: KdfType,
|
||||
kdfConfig: KdfConfig,
|
||||
orgIdentifier: string,
|
||||
keys: KeysRequest
|
||||
keys: KeysRequest,
|
||||
) {
|
||||
this.key = key;
|
||||
this.kdf = kdf;
|
||||
|
||||
@@ -21,7 +21,7 @@ export class SetPasswordRequest {
|
||||
kdf: KdfType,
|
||||
kdfIterations: number,
|
||||
kdfMemory?: number,
|
||||
kdfParallelism?: number
|
||||
kdfParallelism?: number,
|
||||
) {
|
||||
this.masterPasswordHash = masterPasswordHash;
|
||||
this.key = key;
|
||||
|
||||
@@ -36,7 +36,7 @@ export class AuthRequestResponse extends BaseResponse {
|
||||
requestDate.getUTCHours(),
|
||||
requestDate.getUTCMinutes(),
|
||||
requestDate.getUTCSeconds(),
|
||||
requestDate.getUTCMilliseconds()
|
||||
requestDate.getUTCMilliseconds(),
|
||||
);
|
||||
|
||||
const dateNow = new Date(Date.now());
|
||||
@@ -47,7 +47,7 @@ export class AuthRequestResponse extends BaseResponse {
|
||||
dateNow.getUTCHours(),
|
||||
dateNow.getUTCMinutes(),
|
||||
dateNow.getUTCSeconds(),
|
||||
dateNow.getUTCMilliseconds()
|
||||
dateNow.getUTCMilliseconds(),
|
||||
);
|
||||
|
||||
this.isExpired = dateNowUTC - requestDateUTC >= RequestTimeOut;
|
||||
|
||||
@@ -7,10 +7,10 @@ export class DeviceVerificationResponse extends BaseResponse {
|
||||
constructor(response: any) {
|
||||
super(response);
|
||||
this.isDeviceVerificationSectionEnabled = this.getResponseProperty(
|
||||
"IsDeviceVerificationSectionEnabled"
|
||||
"IsDeviceVerificationSectionEnabled",
|
||||
);
|
||||
this.unknownDeviceVerificationEnabled = this.getResponseProperty(
|
||||
"UnknownDeviceVerificationEnabled"
|
||||
"UnknownDeviceVerificationEnabled",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,12 +44,12 @@ export class IdentityTokenResponse extends BaseResponse {
|
||||
this.apiUseKeyConnector = this.getResponseProperty("ApiUseKeyConnector");
|
||||
this.keyConnectorUrl = this.getResponseProperty("KeyConnectorUrl");
|
||||
this.masterPasswordPolicy = new MasterPasswordPolicyResponse(
|
||||
this.getResponseProperty("MasterPasswordPolicy")
|
||||
this.getResponseProperty("MasterPasswordPolicy"),
|
||||
);
|
||||
|
||||
if (response.UserDecryptionOptions) {
|
||||
this.userDecryptionOptions = new UserDecryptionOptionsResponse(
|
||||
this.getResponseProperty("UserDecryptionOptions")
|
||||
this.getResponseProperty("UserDecryptionOptions"),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ export class IdentityTwoFactorResponse extends BaseResponse {
|
||||
}
|
||||
}
|
||||
this.masterPasswordPolicy = new MasterPasswordPolicyResponse(
|
||||
this.getResponseProperty("MasterPasswordPolicy")
|
||||
this.getResponseProperty("MasterPasswordPolicy"),
|
||||
);
|
||||
|
||||
this.ssoEmail2faSessionToken = this.getResponseProperty("SsoEmail2faSessionToken");
|
||||
|
||||
@@ -22,7 +22,7 @@ export class TrustedDeviceUserDecryptionOptionResponse extends BaseResponse {
|
||||
|
||||
this.hasLoginApprovingDevice = this.getResponseProperty("HasLoginApprovingDevice");
|
||||
this.hasManageResetPasswordPermission = this.getResponseProperty(
|
||||
"HasManageResetPasswordPermission"
|
||||
"HasManageResetPasswordPermission",
|
||||
);
|
||||
|
||||
if (response.EncryptedPrivateKey) {
|
||||
|
||||
@@ -33,17 +33,17 @@ export class UserDecryptionOptionsResponse extends BaseResponse {
|
||||
|
||||
if (response.TrustedDeviceOption) {
|
||||
this.trustedDeviceOption = new TrustedDeviceUserDecryptionOptionResponse(
|
||||
this.getResponseProperty("TrustedDeviceOption")
|
||||
this.getResponseProperty("TrustedDeviceOption"),
|
||||
);
|
||||
}
|
||||
if (response.KeyConnectorOption) {
|
||||
this.keyConnectorOption = new KeyConnectorUserDecryptionOptionResponse(
|
||||
this.getResponseProperty("KeyConnectorOption")
|
||||
this.getResponseProperty("KeyConnectorOption"),
|
||||
);
|
||||
}
|
||||
if (response.WebAuthnPrfOption) {
|
||||
this.webAuthnPrfOption = new WebAuthnPrfDecryptionOptionResponse(
|
||||
this.getResponseProperty("WebAuthnPrfOption")
|
||||
this.getResponseProperty("WebAuthnPrfOption"),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import { AssertionOptionsResponse } from "../../../services/webauthn-login/response/assertion-options.response";
|
||||
|
||||
export class WebAuthnLoginCredentialAssertionOptionsView {
|
||||
constructor(readonly options: AssertionOptionsResponse, readonly token: string) {}
|
||||
constructor(
|
||||
readonly options: AssertionOptionsResponse,
|
||||
readonly token: string,
|
||||
) {}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,6 @@ export class WebAuthnLoginCredentialAssertionView {
|
||||
constructor(
|
||||
readonly token: string,
|
||||
readonly deviceResponse: WebAuthnLoginAssertionResponseRequest,
|
||||
readonly prfKey?: PrfKey
|
||||
readonly prfKey?: PrfKey,
|
||||
) {}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ export class AccountApiServiceImplementation implements AccountApiService {
|
||||
private apiService: ApiService,
|
||||
private userVerificationService: UserVerificationService,
|
||||
private logService: LogService,
|
||||
private accountService: InternalAccountService
|
||||
private accountService: InternalAccountService,
|
||||
) {}
|
||||
|
||||
async deleteAccount(verification: Verification): Promise<void> {
|
||||
|
||||
@@ -21,7 +21,7 @@ export const ACCOUNT_ACCOUNTS = KeyDefinition.record<AccountInfo, UserId>(
|
||||
"accounts",
|
||||
{
|
||||
deserializer: (accountInfo) => accountInfo,
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
export const ACCOUNT_ACTIVE_ACCOUNT_ID = new KeyDefinition(ACCOUNT_MEMORY, "activeAccountId", {
|
||||
@@ -42,19 +42,19 @@ export class AccountServiceImplementation implements InternalAccountService {
|
||||
constructor(
|
||||
private messagingService: MessagingService,
|
||||
private logService: LogService,
|
||||
private globalStateProvider: GlobalStateProvider
|
||||
private globalStateProvider: GlobalStateProvider,
|
||||
) {
|
||||
this.accountsState = this.globalStateProvider.get(ACCOUNT_ACCOUNTS);
|
||||
this.activeAccountIdState = this.globalStateProvider.get(ACCOUNT_ACTIVE_ACCOUNT_ID);
|
||||
|
||||
this.accounts$ = this.accountsState.state$.pipe(
|
||||
map((accounts) => (accounts == null ? {} : accounts))
|
||||
map((accounts) => (accounts == null ? {} : accounts)),
|
||||
);
|
||||
this.activeAccount$ = this.activeAccountIdState.state$.pipe(
|
||||
combineLatestWith(this.accounts$),
|
||||
map(([id, accounts]) => (id ? { id, ...accounts[id] } : undefined)),
|
||||
distinctUntilChanged((a, b) => a?.id === b?.id && accountInfoEqual(a, b)),
|
||||
shareReplay({ bufferSize: 1, refCount: false })
|
||||
shareReplay({ bufferSize: 1, refCount: false }),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ export class AccountServiceImplementation implements InternalAccountService {
|
||||
// update only if userId changes
|
||||
return id !== userId;
|
||||
},
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ export class AccountServiceImplementation implements InternalAccountService {
|
||||
|
||||
return !accountInfoEqual(accounts[userId], newAccountInfo(accounts[userId]));
|
||||
},
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ export class AnonymousHubService implements AnonymousHubServiceAbstraction {
|
||||
constructor(
|
||||
private environmentService: EnvironmentService,
|
||||
private authService: AuthService,
|
||||
private logService: LogService
|
||||
private logService: LogService,
|
||||
) {}
|
||||
|
||||
async createHubConnection(token: string) {
|
||||
@@ -51,7 +51,7 @@ export class AnonymousHubService implements AnonymousHubServiceAbstraction {
|
||||
|
||||
private async ProcessNotification(notification: NotificationResponse) {
|
||||
await this.authService.authResponsePushNotification(
|
||||
notification.payload as AuthRequestPushNotification
|
||||
notification.payload as AuthRequestPushNotification,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,23 +13,23 @@ export class AuthRequestCryptoServiceImplementation implements AuthRequestCrypto
|
||||
|
||||
async setUserKeyAfterDecryptingSharedUserKey(
|
||||
authReqResponse: AuthRequestResponse,
|
||||
authReqPrivateKey: Uint8Array
|
||||
authReqPrivateKey: Uint8Array,
|
||||
) {
|
||||
const userKey = await this.decryptPubKeyEncryptedUserKey(
|
||||
authReqResponse.key,
|
||||
authReqPrivateKey
|
||||
authReqPrivateKey,
|
||||
);
|
||||
await this.cryptoService.setUserKey(userKey);
|
||||
}
|
||||
|
||||
async setKeysAfterDecryptingSharedMasterKeyAndHash(
|
||||
authReqResponse: AuthRequestResponse,
|
||||
authReqPrivateKey: Uint8Array
|
||||
authReqPrivateKey: Uint8Array,
|
||||
) {
|
||||
const { masterKey, masterKeyHash } = await this.decryptPubKeyEncryptedMasterKeyAndHash(
|
||||
authReqResponse.key,
|
||||
authReqResponse.masterPasswordHash,
|
||||
authReqPrivateKey
|
||||
authReqPrivateKey,
|
||||
);
|
||||
|
||||
// Decrypt and set user key in state
|
||||
@@ -45,11 +45,11 @@ export class AuthRequestCryptoServiceImplementation implements AuthRequestCrypto
|
||||
// Decryption helpers
|
||||
async decryptPubKeyEncryptedUserKey(
|
||||
pubKeyEncryptedUserKey: string,
|
||||
privateKey: Uint8Array
|
||||
privateKey: Uint8Array,
|
||||
): Promise<UserKey> {
|
||||
const decryptedUserKeyBytes = await this.cryptoService.rsaDecrypt(
|
||||
pubKeyEncryptedUserKey,
|
||||
privateKey
|
||||
privateKey,
|
||||
);
|
||||
|
||||
return new SymmetricCryptoKey(decryptedUserKeyBytes) as UserKey;
|
||||
@@ -58,16 +58,16 @@ export class AuthRequestCryptoServiceImplementation implements AuthRequestCrypto
|
||||
async decryptPubKeyEncryptedMasterKeyAndHash(
|
||||
pubKeyEncryptedMasterKey: string,
|
||||
pubKeyEncryptedMasterKeyHash: string,
|
||||
privateKey: Uint8Array
|
||||
privateKey: Uint8Array,
|
||||
): Promise<{ masterKey: MasterKey; masterKeyHash: string }> {
|
||||
const decryptedMasterKeyArrayBuffer = await this.cryptoService.rsaDecrypt(
|
||||
pubKeyEncryptedMasterKey,
|
||||
privateKey
|
||||
privateKey,
|
||||
);
|
||||
|
||||
const decryptedMasterKeyHashArrayBuffer = await this.cryptoService.rsaDecrypt(
|
||||
pubKeyEncryptedMasterKeyHash,
|
||||
privateKey
|
||||
privateKey,
|
||||
);
|
||||
|
||||
const masterKey = new SymmetricCryptoKey(decryptedMasterKeyArrayBuffer) as MasterKey;
|
||||
|
||||
@@ -47,13 +47,13 @@ describe("AuthRequestCryptoService", () => {
|
||||
// Act
|
||||
await authReqCryptoService.setUserKeyAfterDecryptingSharedUserKey(
|
||||
mockAuthReqResponse,
|
||||
mockPrivateKey
|
||||
mockPrivateKey,
|
||||
);
|
||||
|
||||
// Assert
|
||||
expect(authReqCryptoService.decryptPubKeyEncryptedUserKey).toBeCalledWith(
|
||||
mockAuthReqResponse.key,
|
||||
mockPrivateKey
|
||||
mockPrivateKey,
|
||||
);
|
||||
expect(cryptoService.setUserKey).toBeCalledWith(mockDecryptedUserKey);
|
||||
});
|
||||
@@ -86,14 +86,14 @@ describe("AuthRequestCryptoService", () => {
|
||||
// Act
|
||||
await authReqCryptoService.setKeysAfterDecryptingSharedMasterKeyAndHash(
|
||||
mockAuthReqResponse,
|
||||
mockPrivateKey
|
||||
mockPrivateKey,
|
||||
);
|
||||
|
||||
// Assert
|
||||
expect(authReqCryptoService.decryptPubKeyEncryptedMasterKeyAndHash).toBeCalledWith(
|
||||
mockAuthReqResponse.key,
|
||||
mockAuthReqResponse.masterPasswordHash,
|
||||
mockPrivateKey
|
||||
mockPrivateKey,
|
||||
);
|
||||
expect(cryptoService.setMasterKey).toBeCalledWith(mockDecryptedMasterKey);
|
||||
expect(cryptoService.setMasterKeyHash).toBeCalledWith(mockDecryptedMasterKeyHash);
|
||||
@@ -114,7 +114,7 @@ describe("AuthRequestCryptoService", () => {
|
||||
// Act
|
||||
const result = await authReqCryptoService.decryptPubKeyEncryptedUserKey(
|
||||
mockPubKeyEncryptedUserKey,
|
||||
mockPrivateKey
|
||||
mockPrivateKey,
|
||||
);
|
||||
|
||||
// Assert
|
||||
@@ -131,7 +131,7 @@ describe("AuthRequestCryptoService", () => {
|
||||
|
||||
const mockDecryptedMasterKeyBytes = new Uint8Array(64);
|
||||
const mockDecryptedMasterKey = new SymmetricCryptoKey(
|
||||
mockDecryptedMasterKeyBytes
|
||||
mockDecryptedMasterKeyBytes,
|
||||
) as MasterKey;
|
||||
const mockDecryptedMasterKeyHashBytes = new Uint8Array(64);
|
||||
const mockDecryptedMasterKeyHash = Utils.fromBufferToUtf8(mockDecryptedMasterKeyHashBytes);
|
||||
@@ -144,19 +144,19 @@ describe("AuthRequestCryptoService", () => {
|
||||
const result = await authReqCryptoService.decryptPubKeyEncryptedMasterKeyAndHash(
|
||||
mockPubKeyEncryptedMasterKey,
|
||||
mockPubKeyEncryptedMasterKeyHash,
|
||||
mockPrivateKey
|
||||
mockPrivateKey,
|
||||
);
|
||||
|
||||
// Assert
|
||||
expect(cryptoService.rsaDecrypt).toHaveBeenNthCalledWith(
|
||||
1,
|
||||
mockPubKeyEncryptedMasterKey,
|
||||
mockPrivateKey
|
||||
mockPrivateKey,
|
||||
);
|
||||
expect(cryptoService.rsaDecrypt).toHaveBeenNthCalledWith(
|
||||
2,
|
||||
mockPubKeyEncryptedMasterKeyHash,
|
||||
mockPrivateKey
|
||||
mockPrivateKey,
|
||||
);
|
||||
expect(result.masterKey).toEqual(mockDecryptedMasterKey);
|
||||
expect(result.masterKeyHash).toEqual(mockDecryptedMasterKeyHash);
|
||||
|
||||
@@ -110,7 +110,7 @@ export class AuthService implements AuthServiceAbstraction {
|
||||
protected passwordStrengthService: PasswordStrengthServiceAbstraction,
|
||||
protected policyService: PolicyService,
|
||||
protected deviceTrustCryptoService: DeviceTrustCryptoServiceAbstraction,
|
||||
protected authReqCryptoService: AuthRequestCryptoServiceAbstraction
|
||||
protected authReqCryptoService: AuthRequestCryptoServiceAbstraction,
|
||||
) {}
|
||||
|
||||
async logIn(
|
||||
@@ -119,7 +119,7 @@ export class AuthService implements AuthServiceAbstraction {
|
||||
| PasswordLoginCredentials
|
||||
| SsoLoginCredentials
|
||||
| AuthRequestLoginCredentials
|
||||
| WebAuthnLoginCredentials
|
||||
| WebAuthnLoginCredentials,
|
||||
): Promise<AuthResult> {
|
||||
this.clearState();
|
||||
|
||||
@@ -144,7 +144,7 @@ export class AuthService implements AuthServiceAbstraction {
|
||||
this.twoFactorService,
|
||||
this.passwordStrengthService,
|
||||
this.policyService,
|
||||
this
|
||||
this,
|
||||
);
|
||||
break;
|
||||
case AuthenticationType.Sso:
|
||||
@@ -161,7 +161,7 @@ export class AuthService implements AuthServiceAbstraction {
|
||||
this.keyConnectorService,
|
||||
this.deviceTrustCryptoService,
|
||||
this.authReqCryptoService,
|
||||
this.i18nService
|
||||
this.i18nService,
|
||||
);
|
||||
break;
|
||||
case AuthenticationType.UserApi:
|
||||
@@ -176,7 +176,7 @@ export class AuthService implements AuthServiceAbstraction {
|
||||
this.stateService,
|
||||
this.twoFactorService,
|
||||
this.environmentService,
|
||||
this.keyConnectorService
|
||||
this.keyConnectorService,
|
||||
);
|
||||
break;
|
||||
case AuthenticationType.AuthRequest:
|
||||
@@ -190,7 +190,7 @@ export class AuthService implements AuthServiceAbstraction {
|
||||
this.logService,
|
||||
this.stateService,
|
||||
this.twoFactorService,
|
||||
this.deviceTrustCryptoService
|
||||
this.deviceTrustCryptoService,
|
||||
);
|
||||
break;
|
||||
case AuthenticationType.WebAuthn:
|
||||
@@ -203,7 +203,7 @@ export class AuthService implements AuthServiceAbstraction {
|
||||
this.messagingService,
|
||||
this.logService,
|
||||
this.stateService,
|
||||
this.twoFactorService
|
||||
this.twoFactorService,
|
||||
);
|
||||
break;
|
||||
}
|
||||
@@ -218,7 +218,7 @@ export class AuthService implements AuthServiceAbstraction {
|
||||
|
||||
async logInTwoFactor(
|
||||
twoFactor: TokenTwoFactorRequest,
|
||||
captchaResponse: string
|
||||
captchaResponse: string,
|
||||
): Promise<AuthResult> {
|
||||
if (this.logInStrategy == null) {
|
||||
throw new Error(this.i18nService.t("sessionTimeout"));
|
||||
@@ -281,7 +281,7 @@ export class AuthService implements AuthServiceAbstraction {
|
||||
// Attempt to get the key from storage and set it in memory
|
||||
const userKey = await this.cryptoService.getUserKeyFromStorage(
|
||||
KeySuffixOptions.Auto,
|
||||
userId
|
||||
userId,
|
||||
);
|
||||
await this.cryptoService.setUserKey(userKey, userId);
|
||||
}
|
||||
@@ -307,7 +307,7 @@ export class AuthService implements AuthServiceAbstraction {
|
||||
kdfConfig = new KdfConfig(
|
||||
preloginResponse.kdfIterations,
|
||||
preloginResponse.kdfMemory,
|
||||
preloginResponse.kdfParallelism
|
||||
preloginResponse.kdfParallelism,
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
@@ -329,7 +329,7 @@ export class AuthService implements AuthServiceAbstraction {
|
||||
async passwordlessLogin(
|
||||
id: string,
|
||||
key: string,
|
||||
requestApproved: boolean
|
||||
requestApproved: boolean,
|
||||
): Promise<AuthRequestResponse> {
|
||||
const pubKey = Utils.fromB64ToArray(key);
|
||||
|
||||
@@ -346,7 +346,7 @@ export class AuthService implements AuthServiceAbstraction {
|
||||
if (masterKeyHash != null) {
|
||||
encryptedMasterKeyHash = await this.cryptoService.rsaEncrypt(
|
||||
Utils.fromUtf8ToArray(masterKeyHash),
|
||||
pubKey
|
||||
pubKey,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
@@ -360,7 +360,7 @@ export class AuthService implements AuthServiceAbstraction {
|
||||
encryptedKey.encryptedString,
|
||||
encryptedMasterKeyHash?.encryptedString,
|
||||
await this.appIdService.getAppId(),
|
||||
requestApproved
|
||||
requestApproved,
|
||||
);
|
||||
return await this.apiService.putAuthRequest(id, request);
|
||||
}
|
||||
@@ -371,7 +371,7 @@ export class AuthService implements AuthServiceAbstraction {
|
||||
| PasswordLoginStrategy
|
||||
| SsoLoginStrategy
|
||||
| AuthRequestLoginStrategy
|
||||
| WebAuthnLoginStrategy
|
||||
| WebAuthnLoginStrategy,
|
||||
) {
|
||||
this.logInStrategy = strategy;
|
||||
this.startSessionTimeout();
|
||||
|
||||
@@ -30,7 +30,7 @@ export class DeviceTrustCryptoService implements DeviceTrustCryptoServiceAbstrac
|
||||
private appIdService: AppIdService,
|
||||
private devicesApiService: DevicesApiServiceAbstraction,
|
||||
private i18nService: I18nService,
|
||||
private platformUtilsService: PlatformUtilsService
|
||||
private platformUtilsService: PlatformUtilsService,
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -67,9 +67,8 @@ export class DeviceTrustCryptoService implements DeviceTrustCryptoServiceAbstrac
|
||||
const deviceKey = await this.makeDeviceKey();
|
||||
|
||||
// Generate asymmetric RSA key pair: devicePrivateKey, devicePublicKey
|
||||
const [devicePublicKey, devicePrivateKey] = await this.cryptoFunctionService.rsaGenerateKeyPair(
|
||||
2048
|
||||
);
|
||||
const [devicePublicKey, devicePrivateKey] =
|
||||
await this.cryptoFunctionService.rsaGenerateKeyPair(2048);
|
||||
|
||||
const [
|
||||
devicePublicKeyEncryptedUserKey,
|
||||
@@ -92,7 +91,7 @@ export class DeviceTrustCryptoService implements DeviceTrustCryptoServiceAbstrac
|
||||
deviceIdentifier,
|
||||
devicePublicKeyEncryptedUserKey.encryptedString,
|
||||
userKeyEncryptedDevicePublicKey.encryptedString,
|
||||
deviceKeyEncryptedDevicePrivateKey.encryptedString
|
||||
deviceKeyEncryptedDevicePrivateKey.encryptedString,
|
||||
);
|
||||
|
||||
// store device key in local/secure storage if enc keys posted to server successfully
|
||||
@@ -121,25 +120,25 @@ export class DeviceTrustCryptoService implements DeviceTrustCryptoServiceAbstrac
|
||||
// Get the keys that are used in rotating a devices keys from the server
|
||||
const currentDeviceKeys = await this.devicesApiService.getDeviceKeys(
|
||||
deviceIdentifier,
|
||||
secretVerificationRequest
|
||||
secretVerificationRequest,
|
||||
);
|
||||
|
||||
// Decrypt the existing device public key with the old user key
|
||||
const decryptedDevicePublicKey = await this.encryptService.decryptToBytes(
|
||||
currentDeviceKeys.encryptedPublicKey,
|
||||
oldUserKey
|
||||
oldUserKey,
|
||||
);
|
||||
|
||||
// Encrypt the brand new user key with the now-decrypted public key for the device
|
||||
const encryptedNewUserKey = await this.cryptoService.rsaEncrypt(
|
||||
newUserKey.key,
|
||||
decryptedDevicePublicKey
|
||||
decryptedDevicePublicKey,
|
||||
);
|
||||
|
||||
// Re-encrypt the device public key with the new user key
|
||||
const encryptedDevicePublicKey = await this.encryptService.encrypt(
|
||||
decryptedDevicePublicKey,
|
||||
newUserKey
|
||||
newUserKey,
|
||||
);
|
||||
|
||||
const currentDeviceUpdateRequest = new DeviceKeysUpdateRequest();
|
||||
@@ -176,7 +175,7 @@ export class DeviceTrustCryptoService implements DeviceTrustCryptoServiceAbstrac
|
||||
async decryptUserKeyWithDeviceKey(
|
||||
encryptedDevicePrivateKey: EncString,
|
||||
encryptedUserKey: EncString,
|
||||
deviceKey?: DeviceKey
|
||||
deviceKey?: DeviceKey,
|
||||
): Promise<UserKey | null> {
|
||||
// If device key provided use it, otherwise try to retrieve from storage
|
||||
deviceKey ||= await this.getDeviceKey();
|
||||
@@ -190,13 +189,13 @@ export class DeviceTrustCryptoService implements DeviceTrustCryptoServiceAbstrac
|
||||
// attempt to decrypt encryptedDevicePrivateKey with device key
|
||||
const devicePrivateKey = await this.encryptService.decryptToBytes(
|
||||
encryptedDevicePrivateKey,
|
||||
deviceKey
|
||||
deviceKey,
|
||||
);
|
||||
|
||||
// Attempt to decrypt encryptedUserDataKey with devicePrivateKey
|
||||
const userKey = await this.cryptoService.rsaDecrypt(
|
||||
encryptedUserKey.encryptedString,
|
||||
devicePrivateKey
|
||||
devicePrivateKey,
|
||||
);
|
||||
|
||||
return new SymmetricCryptoKey(userKey) as UserKey;
|
||||
|
||||
@@ -45,7 +45,7 @@ describe("deviceTrustCryptoService", () => {
|
||||
appIdService,
|
||||
devicesApiService,
|
||||
i18nService,
|
||||
platformUtilsService
|
||||
platformUtilsService,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -118,7 +118,7 @@ describe("deviceTrustCryptoService", () => {
|
||||
|
||||
beforeEach(() => {
|
||||
existingDeviceKey = new SymmetricCryptoKey(
|
||||
new Uint8Array(deviceKeyBytesLength) as CsprngArray
|
||||
new Uint8Array(deviceKeyBytesLength) as CsprngArray,
|
||||
) as DeviceKey;
|
||||
|
||||
stateSvcGetDeviceKeySpy = jest.spyOn(stateService, "getDeviceKey");
|
||||
@@ -152,7 +152,7 @@ describe("deviceTrustCryptoService", () => {
|
||||
const stateSvcSetDeviceKeySpy = jest.spyOn(stateService, "setDeviceKey");
|
||||
|
||||
const deviceKey = new SymmetricCryptoKey(
|
||||
new Uint8Array(deviceKeyBytesLength) as CsprngArray
|
||||
new Uint8Array(deviceKeyBytesLength) as CsprngArray,
|
||||
) as DeviceKey;
|
||||
|
||||
// TypeScript will allow calling private methods if the object is of type 'any'
|
||||
@@ -236,17 +236,17 @@ describe("deviceTrustCryptoService", () => {
|
||||
|
||||
mockDevicePublicKeyEncryptedUserKey = new EncString(
|
||||
EncryptionType.Rsa2048_OaepSha1_B64,
|
||||
"mockDevicePublicKeyEncryptedUserKey"
|
||||
"mockDevicePublicKeyEncryptedUserKey",
|
||||
);
|
||||
|
||||
mockUserKeyEncryptedDevicePublicKey = new EncString(
|
||||
EncryptionType.AesCbc256_HmacSha256_B64,
|
||||
"mockUserKeyEncryptedDevicePublicKey"
|
||||
"mockUserKeyEncryptedDevicePublicKey",
|
||||
);
|
||||
|
||||
mockDeviceKeyEncryptedDevicePrivateKey = new EncString(
|
||||
EncryptionType.AesCbc256_HmacSha256_B64,
|
||||
"mockDeviceKeyEncryptedDevicePrivateKey"
|
||||
"mockDeviceKeyEncryptedDevicePrivateKey",
|
||||
);
|
||||
|
||||
// TypeScript will allow calling private methods if the object is of type 'any'
|
||||
@@ -307,7 +307,7 @@ describe("deviceTrustCryptoService", () => {
|
||||
mockDeviceId,
|
||||
mockDevicePublicKeyEncryptedUserKey.encryptedString,
|
||||
mockUserKeyEncryptedDevicePublicKey.encryptedString,
|
||||
mockDeviceKeyEncryptedDevicePrivateKey.encryptedString
|
||||
mockDeviceKeyEncryptedDevicePrivateKey.encryptedString,
|
||||
);
|
||||
|
||||
expect(response).toBeInstanceOf(DeviceResponse);
|
||||
@@ -319,7 +319,7 @@ describe("deviceTrustCryptoService", () => {
|
||||
cryptoSvcGetUserKeySpy.mockResolvedValue(null);
|
||||
// check if the expected error is thrown
|
||||
await expect(deviceTrustCryptoService.trustDevice()).rejects.toThrow(
|
||||
"User symmetric key not found"
|
||||
"User symmetric key not found",
|
||||
);
|
||||
|
||||
// reset the spy
|
||||
@@ -329,7 +329,7 @@ describe("deviceTrustCryptoService", () => {
|
||||
cryptoSvcGetUserKeySpy.mockResolvedValue(undefined);
|
||||
// check if the expected error is thrown
|
||||
await expect(deviceTrustCryptoService.trustDevice()).rejects.toThrow(
|
||||
"User symmetric key not found"
|
||||
"User symmetric key not found",
|
||||
);
|
||||
});
|
||||
|
||||
@@ -377,9 +377,9 @@ describe("deviceTrustCryptoService", () => {
|
||||
const methodSpy = spy();
|
||||
methodSpy.mockResolvedValue(invalidValue);
|
||||
await expect(deviceTrustCryptoService.trustDevice()).rejects.toThrow();
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
@@ -398,12 +398,12 @@ describe("deviceTrustCryptoService", () => {
|
||||
|
||||
mockEncryptedDevicePrivateKey = new EncString(
|
||||
EncryptionType.AesCbc256_HmacSha256_B64,
|
||||
"mockEncryptedDevicePrivateKey"
|
||||
"mockEncryptedDevicePrivateKey",
|
||||
);
|
||||
|
||||
mockEncryptedUserKey = new EncString(
|
||||
EncryptionType.AesCbc256_HmacSha256_B64,
|
||||
"mockEncryptedUserKey"
|
||||
"mockEncryptedUserKey",
|
||||
);
|
||||
|
||||
jest.clearAllMocks();
|
||||
@@ -416,7 +416,7 @@ describe("deviceTrustCryptoService", () => {
|
||||
|
||||
const result = await deviceTrustCryptoService.decryptUserKeyWithDeviceKey(
|
||||
mockEncryptedDevicePrivateKey,
|
||||
mockEncryptedUserKey
|
||||
mockEncryptedUserKey,
|
||||
);
|
||||
|
||||
expect(result).toBeNull();
|
||||
@@ -435,7 +435,7 @@ describe("deviceTrustCryptoService", () => {
|
||||
const result = await deviceTrustCryptoService.decryptUserKeyWithDeviceKey(
|
||||
mockEncryptedDevicePrivateKey,
|
||||
mockEncryptedUserKey,
|
||||
mockDeviceKey
|
||||
mockDeviceKey,
|
||||
);
|
||||
|
||||
expect(result).toEqual(mockUserKey);
|
||||
@@ -458,7 +458,7 @@ describe("deviceTrustCryptoService", () => {
|
||||
// Call without providing a device key
|
||||
const result = await deviceTrustCryptoService.decryptUserKeyWithDeviceKey(
|
||||
mockEncryptedDevicePrivateKey,
|
||||
mockEncryptedUserKey
|
||||
mockEncryptedUserKey,
|
||||
);
|
||||
|
||||
expect(getDeviceKeySpy).toHaveBeenCalledTimes(1);
|
||||
@@ -477,7 +477,7 @@ describe("deviceTrustCryptoService", () => {
|
||||
const result = await deviceTrustCryptoService.decryptUserKeyWithDeviceKey(
|
||||
mockEncryptedDevicePrivateKey,
|
||||
mockEncryptedUserKey,
|
||||
mockDeviceKey
|
||||
mockDeviceKey,
|
||||
);
|
||||
|
||||
expect(result).toBeNull();
|
||||
@@ -511,7 +511,7 @@ describe("deviceTrustCryptoService", () => {
|
||||
describe("is on a trusted device", () => {
|
||||
beforeEach(() => {
|
||||
stateService.getDeviceKey.mockResolvedValue(
|
||||
new SymmetricCryptoKey(new Uint8Array(deviceKeyBytesLength)) as DeviceKey
|
||||
new SymmetricCryptoKey(new Uint8Array(deviceKeyBytesLength)) as DeviceKey,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -525,7 +525,7 @@ describe("deviceTrustCryptoService", () => {
|
||||
|
||||
// Mock the retrieval of a user key that differs from the new one passed into the method
|
||||
stateService.getUserKey.mockResolvedValue(
|
||||
new SymmetricCryptoKey(fakeOldUserKeyData) as UserKey
|
||||
new SymmetricCryptoKey(fakeOldUserKeyData) as UserKey,
|
||||
);
|
||||
|
||||
appIdService.getAppId.mockResolvedValue("test_device_identifier");
|
||||
@@ -547,7 +547,7 @@ describe("deviceTrustCryptoService", () => {
|
||||
type: DeviceType.FirefoxBrowser,
|
||||
encryptedPublicKey: currentEncryptedPublicKey.encryptedString,
|
||||
encryptedUserKey: currentEncryptedUserKey.encryptedString,
|
||||
})
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -576,7 +576,7 @@ describe("deviceTrustCryptoService", () => {
|
||||
|
||||
expect(new Uint8Array(key.key)[0]).toBe(FakeNewUserKeyMarker);
|
||||
return Promise.resolve(
|
||||
new EncString("2.ZW5jcnlwdGVkcHVibGlj|ZW5jcnlwdGVkcHVibGlj|ZW5jcnlwdGVkcHVibGlj")
|
||||
new EncString("2.ZW5jcnlwdGVkcHVibGlj|ZW5jcnlwdGVkcHVibGlj|ZW5jcnlwdGVkcHVibGlj"),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -589,7 +589,7 @@ describe("deviceTrustCryptoService", () => {
|
||||
"2.ZW5jcnlwdGVkcHVibGlj|ZW5jcnlwdGVkcHVibGlj|ZW5jcnlwdGVkcHVibGlj" &&
|
||||
updateTrustModel.currentDevice.encryptedUserKey === "4.ZW5jcnlwdGVkdXNlcg=="
|
||||
);
|
||||
})
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -23,7 +23,7 @@ export class DevicesApiServiceImplementation implements DevicesApiServiceAbstrac
|
||||
(headers) => {
|
||||
headers.set("X-Device-Identifier", deviceIdentifier);
|
||||
headers.set("X-Request-Email", Utils.fromUtf8ToUrlB64(email));
|
||||
}
|
||||
},
|
||||
);
|
||||
return r as boolean;
|
||||
}
|
||||
@@ -38,7 +38,7 @@ export class DevicesApiServiceImplementation implements DevicesApiServiceAbstrac
|
||||
`/devices/identifier/${deviceIdentifier}`,
|
||||
null,
|
||||
true,
|
||||
true
|
||||
true,
|
||||
);
|
||||
return new DeviceResponse(r);
|
||||
}
|
||||
@@ -52,12 +52,12 @@ export class DevicesApiServiceImplementation implements DevicesApiServiceAbstrac
|
||||
deviceIdentifier: string,
|
||||
devicePublicKeyEncryptedUserKey: string,
|
||||
userKeyEncryptedDevicePublicKey: string,
|
||||
deviceKeyEncryptedDevicePrivateKey: string
|
||||
deviceKeyEncryptedDevicePrivateKey: string,
|
||||
): Promise<DeviceResponse> {
|
||||
const request = new TrustedDeviceKeysRequest(
|
||||
devicePublicKeyEncryptedUserKey,
|
||||
userKeyEncryptedDevicePublicKey,
|
||||
deviceKeyEncryptedDevicePrivateKey
|
||||
deviceKeyEncryptedDevicePrivateKey,
|
||||
);
|
||||
|
||||
const result = await this.apiService.send(
|
||||
@@ -65,7 +65,7 @@ export class DevicesApiServiceImplementation implements DevicesApiServiceAbstrac
|
||||
`/devices/${deviceIdentifier}/keys`,
|
||||
request,
|
||||
true,
|
||||
true
|
||||
true,
|
||||
);
|
||||
|
||||
return new DeviceResponse(result);
|
||||
@@ -77,20 +77,20 @@ export class DevicesApiServiceImplementation implements DevicesApiServiceAbstrac
|
||||
"/devices/update-trust",
|
||||
updateDevicesTrustRequestModel,
|
||||
true,
|
||||
false
|
||||
false,
|
||||
);
|
||||
}
|
||||
|
||||
async getDeviceKeys(
|
||||
deviceIdentifier: string,
|
||||
secretVerificationRequest: SecretVerificationRequest
|
||||
secretVerificationRequest: SecretVerificationRequest,
|
||||
): Promise<ProtectedDeviceResponse> {
|
||||
const result = await this.apiService.send(
|
||||
"POST",
|
||||
`/devices/${deviceIdentifier}/retrieve-keys`,
|
||||
secretVerificationRequest,
|
||||
true,
|
||||
true
|
||||
true,
|
||||
);
|
||||
return new ProtectedDeviceResponse(result);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ export class DevicesServiceImplementation implements DevicesServiceAbstraction {
|
||||
return deviceResponses.data.map((deviceResponse: DeviceResponse) => {
|
||||
return new DeviceView(deviceResponse);
|
||||
});
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ export class DevicesServiceImplementation implements DevicesServiceAbstraction {
|
||||
*/
|
||||
getDeviceByIdentifier$(deviceIdentifier: string): Observable<DeviceView> {
|
||||
return defer(() => this.devicesApiService.getDeviceByIdentifier(deviceIdentifier)).pipe(
|
||||
map((deviceResponse: DeviceResponse) => new DeviceView(deviceResponse))
|
||||
map((deviceResponse: DeviceResponse) => new DeviceView(deviceResponse)),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -54,15 +54,15 @@ export class DevicesServiceImplementation implements DevicesServiceAbstraction {
|
||||
deviceIdentifier: string,
|
||||
devicePublicKeyEncryptedUserKey: string,
|
||||
userKeyEncryptedDevicePublicKey: string,
|
||||
deviceKeyEncryptedDevicePrivateKey: string
|
||||
deviceKeyEncryptedDevicePrivateKey: string,
|
||||
): Observable<DeviceView> {
|
||||
return defer(() =>
|
||||
this.devicesApiService.updateTrustedDeviceKeys(
|
||||
deviceIdentifier,
|
||||
devicePublicKeyEncryptedUserKey,
|
||||
userKeyEncryptedDevicePublicKey,
|
||||
deviceKeyEncryptedDevicePrivateKey
|
||||
)
|
||||
deviceKeyEncryptedDevicePrivateKey,
|
||||
),
|
||||
).pipe(map((deviceResponse: DeviceResponse) => new DeviceView(deviceResponse)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,6 @@ export class TrustedDeviceKeysRequest {
|
||||
constructor(
|
||||
public encryptedUserKey: string,
|
||||
public encryptedPublicKey: string,
|
||||
public encryptedPrivateKey: string
|
||||
public encryptedPrivateKey: string,
|
||||
) {}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ export class KeyConnectorService implements KeyConnectorServiceAbstraction {
|
||||
private logService: LogService,
|
||||
private organizationService: OrganizationService,
|
||||
private cryptoFunctionService: CryptoFunctionService,
|
||||
private logoutCallback: (expired: boolean, userId?: string) => Promise<void>
|
||||
private logoutCallback: (expired: boolean, userId?: string) => Promise<void>,
|
||||
) {}
|
||||
|
||||
setUsesKeyConnector(usesKeyConnector: boolean) {
|
||||
@@ -51,7 +51,7 @@ export class KeyConnectorService implements KeyConnectorServiceAbstraction {
|
||||
try {
|
||||
await this.apiService.postUserKeyToKeyConnector(
|
||||
organization.keyConnectorUrl,
|
||||
keyConnectorRequest
|
||||
keyConnectorRequest,
|
||||
);
|
||||
} catch (e) {
|
||||
this.handleKeyConnectorError(e);
|
||||
@@ -79,7 +79,7 @@ export class KeyConnectorService implements KeyConnectorServiceAbstraction {
|
||||
o.keyConnectorEnabled &&
|
||||
o.type !== OrganizationUserType.Admin &&
|
||||
o.type !== OrganizationUserType.Owner &&
|
||||
!o.isProviderUser
|
||||
!o.isProviderUser,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ export class KeyConnectorService implements KeyConnectorServiceAbstraction {
|
||||
Utils.fromBufferToB64(password),
|
||||
await this.tokenService.getEmail(),
|
||||
kdf,
|
||||
kdfConfig
|
||||
kdfConfig,
|
||||
);
|
||||
const keyConnectorRequest = new KeyConnectorUserKeyRequest(masterKey.encKeyB64);
|
||||
await this.cryptoService.setMasterKey(masterKey);
|
||||
@@ -125,7 +125,7 @@ export class KeyConnectorService implements KeyConnectorServiceAbstraction {
|
||||
kdf,
|
||||
kdfConfig,
|
||||
orgId,
|
||||
keys
|
||||
keys,
|
||||
);
|
||||
await this.apiService.postSetKeyConnectorKey(setPasswordRequest);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ describe("PasswordResetEnrollmentServiceImplementation", () => {
|
||||
stateService,
|
||||
cryptoService,
|
||||
organizationUserService,
|
||||
i18nService
|
||||
i18nService,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -88,13 +88,13 @@ describe("PasswordResetEnrollmentServiceImplementation", () => {
|
||||
await service.enroll("orgId");
|
||||
|
||||
expect(
|
||||
organizationUserService.putOrganizationUserResetPasswordEnrollment
|
||||
organizationUserService.putOrganizationUserResetPasswordEnrollment,
|
||||
).toHaveBeenCalledWith(
|
||||
"orgId",
|
||||
"userId",
|
||||
expect.objectContaining({
|
||||
resetPasswordKey: encryptedKey.encryptedString,
|
||||
})
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -110,13 +110,13 @@ describe("PasswordResetEnrollmentServiceImplementation", () => {
|
||||
await service.enroll("orgId", "userId", { key: "key" } as any);
|
||||
|
||||
expect(
|
||||
organizationUserService.putOrganizationUserResetPasswordEnrollment
|
||||
organizationUserService.putOrganizationUserResetPasswordEnrollment,
|
||||
).toHaveBeenCalledWith(
|
||||
"orgId",
|
||||
"userId",
|
||||
expect.objectContaining({
|
||||
resetPasswordKey: encryptedKey.encryptedString,
|
||||
})
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -16,13 +16,12 @@ export class PasswordResetEnrollmentServiceImplementation
|
||||
protected stateService: StateService,
|
||||
protected cryptoService: CryptoService,
|
||||
protected organizationUserService: OrganizationUserService,
|
||||
protected i18nService: I18nService
|
||||
protected i18nService: I18nService,
|
||||
) {}
|
||||
|
||||
async enrollIfRequired(organizationSsoIdentifier: string): Promise<void> {
|
||||
const orgAutoEnrollStatusResponse = await this.organizationApiService.getAutoEnrollStatus(
|
||||
organizationSsoIdentifier
|
||||
);
|
||||
const orgAutoEnrollStatusResponse =
|
||||
await this.organizationApiService.getAutoEnrollStatus(organizationSsoIdentifier);
|
||||
|
||||
if (!orgAutoEnrollStatusResponse.resetPasswordEnabled) {
|
||||
await this.enroll(orgAutoEnrollStatusResponse.id, null, null);
|
||||
@@ -50,7 +49,7 @@ export class PasswordResetEnrollmentServiceImplementation
|
||||
await this.organizationUserService.putOrganizationUserResetPasswordEnrollment(
|
||||
organizationId,
|
||||
userId,
|
||||
resetRequest
|
||||
resetRequest,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ export class TokenService implements TokenServiceAbstraction {
|
||||
async setTokens(
|
||||
accessToken: string,
|
||||
refreshToken: string,
|
||||
clientIdClientSecret: [string, string]
|
||||
clientIdClientSecret: [string, string],
|
||||
): Promise<any> {
|
||||
await this.setToken(accessToken);
|
||||
await this.setRefreshToken(refreshToken);
|
||||
|
||||
@@ -65,7 +65,7 @@ export class TwoFactorService implements TwoFactorServiceAbstraction {
|
||||
|
||||
constructor(
|
||||
private i18nService: I18nService,
|
||||
private platformUtilsService: PlatformUtilsService
|
||||
private platformUtilsService: PlatformUtilsService,
|
||||
) {}
|
||||
|
||||
init() {
|
||||
|
||||
@@ -17,7 +17,7 @@ export class UserVerificationService implements UserVerificationServiceAbstracti
|
||||
private stateService: StateService,
|
||||
private cryptoService: CryptoService,
|
||||
private i18nService: I18nService,
|
||||
private userVerificationApiService: UserVerificationApiServiceAbstraction
|
||||
private userVerificationApiService: UserVerificationApiServiceAbstraction,
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -29,7 +29,7 @@ export class UserVerificationService implements UserVerificationServiceAbstracti
|
||||
async buildRequest<T extends SecretVerificationRequest>(
|
||||
verification: Verification,
|
||||
requestClass?: new () => T,
|
||||
alreadyHashed?: boolean
|
||||
alreadyHashed?: boolean,
|
||||
) {
|
||||
this.validateInput(verification);
|
||||
|
||||
@@ -45,7 +45,7 @@ export class UserVerificationService implements UserVerificationServiceAbstracti
|
||||
verification.secret,
|
||||
await this.stateService.getEmail(),
|
||||
await this.stateService.getKdfType(),
|
||||
await this.stateService.getKdfConfig()
|
||||
await this.stateService.getKdfConfig(),
|
||||
);
|
||||
}
|
||||
request.masterPasswordHash = alreadyHashed
|
||||
@@ -78,12 +78,12 @@ export class UserVerificationService implements UserVerificationServiceAbstracti
|
||||
verification.secret,
|
||||
await this.stateService.getEmail(),
|
||||
await this.stateService.getKdfType(),
|
||||
await this.stateService.getKdfConfig()
|
||||
await this.stateService.getKdfConfig(),
|
||||
);
|
||||
}
|
||||
const passwordValid = await this.cryptoService.compareAndUpdateKeyHash(
|
||||
verification.secret,
|
||||
masterKey
|
||||
masterKey,
|
||||
);
|
||||
if (!passwordValid) {
|
||||
throw new Error(this.i18nService.t("invalidMasterPassword"));
|
||||
|
||||
@@ -5,7 +5,10 @@ import { WebAuthnLoginApiServiceAbstraction } from "../../abstractions/webauthn/
|
||||
import { CredentialAssertionOptionsResponse } from "./response/credential-assertion-options.response";
|
||||
|
||||
export class WebAuthnLoginApiService implements WebAuthnLoginApiServiceAbstraction {
|
||||
constructor(private apiService: ApiService, private environmentService: EnvironmentService) {}
|
||||
constructor(
|
||||
private apiService: ApiService,
|
||||
private environmentService: EnvironmentService,
|
||||
) {}
|
||||
|
||||
async getCredentialAssertionOptions(): Promise<CredentialAssertionOptionsResponse> {
|
||||
const response = await this.apiService.send(
|
||||
@@ -14,7 +17,7 @@ export class WebAuthnLoginApiService implements WebAuthnLoginApiServiceAbstracti
|
||||
null,
|
||||
false,
|
||||
true,
|
||||
this.environmentService.getIdentityUrl()
|
||||
this.environmentService.getIdentityUrl(),
|
||||
);
|
||||
return new CredentialAssertionOptionsResponse(response);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ describe("WebAuthnLoginPrfCryptoService", () => {
|
||||
describe("createSymmetricKeyFromPrf", () => {
|
||||
it("should stretch the key to 64 bytes when given a key with 32 bytes", async () => {
|
||||
cryptoFunctionService.hkdfExpand.mockImplementation((key, salt, length) =>
|
||||
Promise.resolve(randomBytes(length))
|
||||
Promise.resolve(randomBytes(length)),
|
||||
);
|
||||
|
||||
const result = await service.createSymmetricKeyFromPrf(randomBytes(32));
|
||||
|
||||
@@ -78,7 +78,7 @@ describe("WebAuthnLoginService", () => {
|
||||
configService,
|
||||
webAuthnLoginPrfCryptoService,
|
||||
window,
|
||||
logService
|
||||
logService,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -135,11 +135,11 @@ describe("WebAuthnLoginService", () => {
|
||||
};
|
||||
|
||||
const mockedCredentialAssertionOptionsResponse = new CredentialAssertionOptionsResponse(
|
||||
mockedCredentialAssertionOptionsServerResponse
|
||||
mockedCredentialAssertionOptionsServerResponse,
|
||||
);
|
||||
|
||||
webAuthnLoginApiService.getCredentialAssertionOptions.mockResolvedValue(
|
||||
mockedCredentialAssertionOptionsResponse
|
||||
mockedCredentialAssertionOptionsResponse,
|
||||
);
|
||||
|
||||
// Act
|
||||
@@ -190,11 +190,11 @@ describe("WebAuthnLoginService", () => {
|
||||
}),
|
||||
}),
|
||||
}),
|
||||
})
|
||||
}),
|
||||
);
|
||||
|
||||
expect(webAuthnLoginPrfCryptoService.createSymmetricKeyFromPrf).toHaveBeenCalledWith(
|
||||
prfResult
|
||||
prfResult,
|
||||
);
|
||||
|
||||
expect(result).toBeInstanceOf(WebAuthnLoginCredentialAssertionView);
|
||||
@@ -320,7 +320,7 @@ class MockPublicKeyCredential implements PublicKeyCredential {
|
||||
// Creating the array buffer from a known hex value allows us to
|
||||
// assert on the value in tests
|
||||
private prfKeyArrayBuffer: ArrayBuffer = Utils.hexStringToArrayBuffer(
|
||||
"1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"
|
||||
"1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
|
||||
);
|
||||
|
||||
getClientExtensionResults(): any {
|
||||
@@ -367,11 +367,11 @@ function buildCredentialAssertionOptions(): WebAuthnLoginCredentialAssertionOpti
|
||||
};
|
||||
|
||||
const credentialAssertionOptionsResponse = new CredentialAssertionOptionsResponse(
|
||||
credentialAssertionOptionsServerResponse
|
||||
credentialAssertionOptionsServerResponse,
|
||||
);
|
||||
|
||||
return new WebAuthnLoginCredentialAssertionOptionsView(
|
||||
credentialAssertionOptionsResponse.options,
|
||||
credentialAssertionOptionsResponse.token
|
||||
credentialAssertionOptionsResponse.token,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ export class WebAuthnLoginService implements WebAuthnLoginServiceAbstraction {
|
||||
private configService: ConfigServiceAbstraction,
|
||||
private webAuthnLoginPrfCryptoService: WebAuthnLoginPrfCryptoServiceAbstraction,
|
||||
private window: Window,
|
||||
private logService?: LogService
|
||||
private logService?: LogService,
|
||||
) {
|
||||
this.enabled$ = this.configService.getFeatureFlag$(FeatureFlag.PasswordlessLogin, false);
|
||||
this.navigatorCredentials = this.window.navigator.credentials;
|
||||
@@ -38,7 +38,7 @@ export class WebAuthnLoginService implements WebAuthnLoginServiceAbstraction {
|
||||
}
|
||||
|
||||
async assertCredential(
|
||||
credentialAssertionOptions: WebAuthnLoginCredentialAssertionOptionsView
|
||||
credentialAssertionOptions: WebAuthnLoginCredentialAssertionOptionsView,
|
||||
): Promise<WebAuthnLoginCredentialAssertionView> {
|
||||
const nativeOptions: CredentialRequestOptions = {
|
||||
publicKey: credentialAssertionOptions.options,
|
||||
@@ -57,9 +57,8 @@ export class WebAuthnLoginService implements WebAuthnLoginServiceAbstraction {
|
||||
const prfResult = (response.getClientExtensionResults() as any).prf?.results?.first;
|
||||
let symmetricPrfKey: PrfKey | undefined;
|
||||
if (prfResult != undefined) {
|
||||
symmetricPrfKey = await this.webAuthnLoginPrfCryptoService.createSymmetricKeyFromPrf(
|
||||
prfResult
|
||||
);
|
||||
symmetricPrfKey =
|
||||
await this.webAuthnLoginPrfCryptoService.createSymmetricKeyFromPrf(prfResult);
|
||||
}
|
||||
|
||||
const deviceResponse = new WebAuthnLoginAssertionResponseRequest(response);
|
||||
@@ -73,7 +72,7 @@ export class WebAuthnLoginService implements WebAuthnLoginServiceAbstraction {
|
||||
return new WebAuthnLoginCredentialAssertionView(
|
||||
credentialAssertionOptions.token,
|
||||
deviceResponse,
|
||||
symmetricPrfKey
|
||||
symmetricPrfKey,
|
||||
);
|
||||
} catch (error) {
|
||||
this.logService?.error(error);
|
||||
@@ -85,7 +84,7 @@ export class WebAuthnLoginService implements WebAuthnLoginServiceAbstraction {
|
||||
const credential = new WebAuthnLoginCredentials(
|
||||
assertion.token,
|
||||
assertion.deviceResponse,
|
||||
assertion.prfKey
|
||||
assertion.prfKey,
|
||||
);
|
||||
const result = await this.authService.logIn(credential);
|
||||
return result;
|
||||
|
||||
@@ -14,7 +14,7 @@ export class WebAuthnIFrame {
|
||||
private i18nService: I18nService,
|
||||
private successCallback: Function, // eslint-disable-line
|
||||
private errorCallback: Function, // eslint-disable-line
|
||||
private infoCallback: Function // eslint-disable-line
|
||||
private infoCallback: Function, // eslint-disable-line
|
||||
) {
|
||||
this.connectorLink = win.document.createElement("a");
|
||||
}
|
||||
@@ -31,7 +31,7 @@ export class WebAuthnIFrame {
|
||||
// Firefox fallback which opens the webauthn page in a new tab
|
||||
params.append("locale", this.i18nService.translationLocale);
|
||||
this.platformUtilsService.launchUri(
|
||||
`${this.webVaultUrl}/webauthn-fallback-connector.html?${params}`
|
||||
`${this.webVaultUrl}/webauthn-fallback-connector.html?${params}`,
|
||||
);
|
||||
} else {
|
||||
this.connectorLink.href = `${this.webVaultUrl}/webauthn-connector.html?${params}`;
|
||||
@@ -63,7 +63,7 @@ export class WebAuthnIFrame {
|
||||
return btoa(
|
||||
encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, (match, p1) => {
|
||||
return String.fromCharCode(("0x" + p1) as any);
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -95,12 +95,12 @@ export class SecretsManagerPlanFeaturesResponse extends BaseResponse {
|
||||
this.maxSeats = this.getResponseProperty("MaxSeats");
|
||||
this.stripeServiceAccountPlanId = this.getResponseProperty("StripeServiceAccountPlanId");
|
||||
this.additionalPricePerServiceAccount = this.getResponseProperty(
|
||||
"AdditionalPricePerServiceAccount"
|
||||
"AdditionalPricePerServiceAccount",
|
||||
);
|
||||
this.baseServiceAccount = this.getResponseProperty("BaseServiceAccount");
|
||||
this.maxServiceAccount = this.getResponseProperty("MaxServiceAccount");
|
||||
this.hasAdditionalServiceAccountOption = this.getResponseProperty(
|
||||
"HasAdditionalServiceAccountOption"
|
||||
"HasAdditionalServiceAccountOption",
|
||||
);
|
||||
this.maxAdditionalServiceAccounts = this.getResponseProperty("MaxAdditionalServiceAccounts");
|
||||
this.maxProjects = this.getResponseProperty("MaxProjects");
|
||||
|
||||
@@ -16,7 +16,7 @@ export class OrganizationImportRequest {
|
||||
overwriteExisting: boolean;
|
||||
largeImport: boolean;
|
||||
}
|
||||
| ImportDirectoryRequest
|
||||
| ImportDirectoryRequest,
|
||||
) {
|
||||
if (model instanceof ImportDirectoryRequest) {
|
||||
this.groups = model.groups.map((g) => new OrganizationImportGroupRequest(g));
|
||||
|
||||
@@ -21,7 +21,7 @@ export class RegisterRequest implements CaptchaProtectedRequest {
|
||||
public kdf: KdfType,
|
||||
public kdfIterations: number,
|
||||
public kdfMemory?: number,
|
||||
public kdfParallelism?: number
|
||||
public kdfParallelism?: number,
|
||||
) {
|
||||
this.masterPasswordHint = masterPasswordHint ? masterPasswordHint : null;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ export abstract class BaseResponse {
|
||||
protected getResponseProperty(
|
||||
propertyName: string,
|
||||
response: any = null,
|
||||
exactName = false
|
||||
exactName = false,
|
||||
): any {
|
||||
if (propertyName == null || propertyName === "") {
|
||||
throw new Error("propertyName must not be null/empty.");
|
||||
|
||||
@@ -11,7 +11,7 @@ export class DomainsResponse extends BaseResponse {
|
||||
const globalEquivalentDomains = this.getResponseProperty("GlobalEquivalentDomains");
|
||||
if (globalEquivalentDomains != null) {
|
||||
this.globalEquivalentDomains = globalEquivalentDomains.map(
|
||||
(d: any) => new GlobalDomainResponse(d)
|
||||
(d: any) => new GlobalDomainResponse(d),
|
||||
);
|
||||
} else {
|
||||
this.globalEquivalentDomains = [];
|
||||
|
||||
@@ -53,7 +53,7 @@ export class ProfileResponse extends BaseResponse {
|
||||
const providerOrganizations = this.getResponseProperty("ProviderOrganizations");
|
||||
if (providerOrganizations != null) {
|
||||
this.providerOrganizations = providerOrganizations.map(
|
||||
(o: any) => new ProfileProviderOrganizationResponse(o)
|
||||
(o: any) => new ProfileProviderOrganizationResponse(o),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user