UNPKG

@sassoftware/vi-api

Version:
188 lines (187 loc) 8.55 kB
import { FieldValue } from "./data-types"; export interface UnmaskEventData { data: { [fieldName: string]: FieldValue; }; fieldNames: string[]; documentId: string; documentType: string; scopeId: string; nodeId?: string; } export interface MaskEventData { fieldNames: string[]; documentId: string; documentType: string; scopeId: string; nodeId?: string; } export interface MaskResetEventData { scopeId: string; documentId: string; fieldNames: string[]; } export declare const MASKED_FIELD_CHAR = "\u2022"; export declare const MASKED_FIELD_PLACEHOLDER: string; export declare const MASKED_FIELD_ISO_CODE_PLACEHOLDER: string; export interface MaskingPageApi { /** * Determines whether a field is masked. * @throws {FieldNotOnPageError} * @param fieldName The field name. * @returns A boolean. */ isMasked(fieldName: string): boolean; /** * Masks a field. * @throws {NotConfiguredForMaskingError} * @throws {FieldNotOnPageError} * @param fieldName The field name. */ mask(fieldName: string): void; /** * Masks the fields. * If no fields array is passed in then all fields that are configured for masking on the page will be masked. * @throws {NotConfiguredForMaskingError} If one or more of the fields are not configured for masking. * @throws {FieldNotOnPageError} If one or more of the fields are not available on the page. * @param fieldNames The field names. */ maskAll(fieldNames?: string[]): void; /** * Unmasks the field via a fetch. * Subsequent get field value calls return the unmasked value. * If the field is unmasked or has been unmasked in the current page mode, no fetch is made. * If the field is not on the page the promise will reject with a {@link FieldNotOnPageError}. * If the field is not configured for masking the promise will reject with a {@link NotConfiguredForMaskingError}. * If the user is not authorized to reveal the field, the returned promise will reject with an {@link UnmaskAuthError}. * @param fieldName The field name. * @returns A promise that resolves when the unmask is successful. */ unmask(fieldName: string): Promise<void>; /** * Unmasks the fields via a fetch. * Subsequent get field value calls return the unmasked value. * If no fields array is passed in then all fields on the page configured for masking will be unmasked. * For each field, if the field is unmasked or has been unmasked in the current page mode, no fetch for it is made. * If one or more of the fields are not on the page the promise will reject with a {@link FieldNotOnPageError}. * If one or more of the fields are not configured for masking the promise will reject with a {@link NotConfiguredForMaskingError}. * If the user is not authorized to reveal one or more of the fields, the returned promise will reject with an {@link UnmaskAuthError}. * @param fieldNames The field names. * @returns A promise that resolves when the unmasks are successful. */ unmaskAll(fieldNames?: string[]): Promise<void>; /** * Invokes the callback whenever any field value is masked. * When an individual field is masked via a mask call, the callback will be invoked once. * When multiple fields are masked via a single mask/mask all call, the callback will be invoked once. * @param callback The callback function. * @returns A function that removes the callback. */ onEveryMask(callback: (mask: { fieldNames: string[]; }) => void): () => void; /** * Invokes the callback whenever the specified field is masked. * @throws {FieldNotOnPageError} * @param fieldName The field name. * @param callback The callback function. * @returns A function that removes the callback. */ onMask(fieldName: string, callback: () => void): () => void; /** * Invokes the callback whenever any field value is unmasked. * When an individual field is unmasked via an unmask call, the callback will be invoked once. * When multiple fields are unmasked via a single unmask/unmask all call, the callback will be invoked once. * @param callback The callback function. * @returns A function that removes the callback. */ onEveryUnmask(callback: (unmask: { fieldNames: string[]; }) => void): () => void; /** * Invokes the callback whenever the specified field is unmasked. * @throws {FieldNotOnPageError} * @param fieldName The field name. * @param callback The callback function. * @returns A function that removes the callback. */ onUnmask(fieldName: string, callback: () => void): () => void; /** * Determines whether the field is configured for masking via the field's restrictions. * @throws {FieldNotOnPageError} * @param fieldName The field name. * @returns Whether the field is configured for masking. */ isConfiguredForMasking(fieldName: string): boolean; /** * Determines whether the current user can unmask the field. * @throws {FieldNotOnPageError} * @throws {NotConfiguredForMaskingError} * @param fieldName The field name. * @returns Whether the current can unmask the field. */ isAuthorizedToUnmask(fieldName: string): boolean; } export interface MaskingControlApi { /** * In the case of a single field control, determines whether the control's field is masked. * In the case of a multiple field control, determines whether one or more of the control's fields are masked. * @returns A boolean. */ isMasked(): boolean; /** * Masks the control's field(s) that are configured for masking. * @throws {NotConfiguredForMaskingError} If a single field control's field is not configured for masking or if * all of a multiple field control's fields are not configured for masking. */ mask(): void; /** * Unmasks the controls field(s) via a fetch. * Subsequent get field value calls return the unmasked value. * For each field, if the field is unmasked or has been unmasked in the current page mode, no fetch for it is made. * If a single field control's field is not configured for masking or if all of a multiple field control's fields are not configured for masking the returned * promise will reject with a {@link NotConfiguredForMaskingError}. * If the user is not authorized to reveal one or more of the control's fields, the returned promise will reject with an {@link UnmaskAuthError}. * @returns A promise that resolves when the unmask is successful. */ unmask(): Promise<void>; /** * Invokes the callback whenever the control's field is (or, in the case of a multiple field control, fields are) masked. * @param callback The callback function. * @returns A function that removes the callback. */ onMask(callback: (mask: { fieldNames: string[]; }) => void): () => void; /** * Invokes the callback whenever the control's field is (or, in the case of a multiple field control, fields are) unmasked. * @param callback The callback function. * @returns A function that removes the callback. */ onUnmask(callback: (unmask: { fieldNames: string[]; }) => void): () => void; /** * In the case of a single field control, determines (via the field restrictions) whether the control's field is configured for masking. * In the case of a multiple field control, determines (via the field restrictions) whether one or more of the control's fields are configured for masking. * @returns Whether the control is configured for masking. */ isConfiguredForMasking(): boolean; /** * In the case of a single field control, determines whether the current user is able to unmask the control's field. * In the case of a multiple field control, determines whether the current user is able to unmask all of the control's fields. * @throws {NotConfiguredForMaskingError} * @returns Whether the current user is able to unmask the control. */ isAuthorizedToUnmask(): boolean; } export interface UnmaskAuthError { name: "UnmaskAuthError"; message: string; fields: string[]; } export interface NotConfiguredForMaskingError { name: "NotConfiguredForMaskingError"; message: string; fields: string[]; }