mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 08:13:42 +00:00
Add additional jsdoc to policyservice (#14934)
This commit is contained in:
@@ -7,6 +7,9 @@ import { MasterPasswordPolicyOptions } from "../../models/domain/master-password
|
|||||||
import { Policy } from "../../models/domain/policy";
|
import { Policy } from "../../models/domain/policy";
|
||||||
import { ResetPasswordPolicyOptions } from "../../models/domain/reset-password-policy-options";
|
import { ResetPasswordPolicyOptions } from "../../models/domain/reset-password-policy-options";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The primary service for retrieving and evaluating policies from sync data.
|
||||||
|
*/
|
||||||
export abstract class PolicyService {
|
export abstract class PolicyService {
|
||||||
/**
|
/**
|
||||||
* All policies for the provided user from sync data.
|
* All policies for the provided user from sync data.
|
||||||
@@ -24,7 +27,7 @@ export abstract class PolicyService {
|
|||||||
abstract policiesByType$: (policyType: PolicyType, userId: UserId) => Observable<Policy[]>;
|
abstract policiesByType$: (policyType: PolicyType, userId: UserId) => Observable<Policy[]>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns true if a policy of the specified type applies to the specified user, otherwise false.
|
* @returns true if any policy of the specified type applies to the specified user, otherwise false.
|
||||||
* A policy "applies" if it is enabled and the user is not exempt (e.g. because they are an Owner).
|
* A policy "applies" if it is enabled and the user is not exempt (e.g. because they are an Owner).
|
||||||
* This does not take into account the policy's configuration - if that is important, use {@link policiesByType$} to get the
|
* This does not take into account the policy's configuration - if that is important, use {@link policiesByType$} to get the
|
||||||
* {@link Policy} objects and then filter by Policy.data.
|
* {@link Policy} objects and then filter by Policy.data.
|
||||||
@@ -35,8 +38,12 @@ export abstract class PolicyService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Combines all Master Password policies that apply to the user.
|
* Combines all Master Password policies that apply to the user.
|
||||||
|
* If you are evaluating Master Password policies before the first sync has completed,
|
||||||
|
* you must supply your own `policies` value.
|
||||||
|
* @param userId The user against whom the policy needs to be enforced.
|
||||||
|
* @param policies The policies to be evaluated; if null or undefined, it will default to using policies from sync data.
|
||||||
* @returns a set of options which represent the minimum Master Password settings that the user must
|
* @returns a set of options which represent the minimum Master Password settings that the user must
|
||||||
* comply with in order to comply with **all** Master Password policies.
|
* comply with in order to comply with **all** applicable Master Password policies.
|
||||||
*/
|
*/
|
||||||
abstract masterPasswordPolicyOptions$: (
|
abstract masterPasswordPolicyOptions$: (
|
||||||
userId: UserId,
|
userId: UserId,
|
||||||
@@ -62,7 +69,17 @@ export abstract class PolicyService {
|
|||||||
) => [ResetPasswordPolicyOptions, boolean];
|
) => [ResetPasswordPolicyOptions, boolean];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An "internal" extension of the `PolicyService` which allows the update of policy data in the local sync data.
|
||||||
|
* This does not update any policies on the server.
|
||||||
|
*/
|
||||||
export abstract class InternalPolicyService extends PolicyService {
|
export abstract class InternalPolicyService extends PolicyService {
|
||||||
|
/**
|
||||||
|
* Upsert a policy in the local sync data. This does not update any policies on the server.
|
||||||
|
*/
|
||||||
abstract upsert: (policy: PolicyData, userId: UserId) => Promise<void>;
|
abstract upsert: (policy: PolicyData, userId: UserId) => Promise<void>;
|
||||||
|
/**
|
||||||
|
* Replace a policy in the local sync data. This does not update any policies on the server.
|
||||||
|
*/
|
||||||
abstract replace: (policies: { [id: string]: PolicyData }, userId: UserId) => Promise<void>;
|
abstract replace: (policies: { [id: string]: PolicyData }, userId: UserId) => Promise<void>;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user