The parameters for creating the store.
Optional
dialogDefaultRemember?: booleanWhether access request dialogs should remember the user's choice by default.
Optional
dismissDenyThreshold?: numberThe number of times an access request can be dismissed before the permission is automatically blocked.
Optional
initialStates?: Map<PermissionDescriptor, PermissionAccessStatus | PermissionAccessState>The initial states of permissions in the store, as a map of permission descriptors to their initial access state.
As well as setting the initial access states, this also defines the set of permissions that are known to the permission store.
States can be specified in full by using PermissionAccessState
objects, or alternatively a PermissionAccessStatus string can be
used, in which case dismissCount
will initialize to 0
.
The result of calling buildInitialPermissionStates.
Optional
isMatchingDescriptor?: (a: PermissionDescriptor, b: PermissionDescriptor) => booleanA custom function to determine whether two permission descriptors match.
Optional
masks?: Map<PermissionDescriptor, Partial<PermissionMask>>Permission masks to apply when mapping PermissionAccessStatus values to PermissionState values for various permissions.
Internally, this library stores more granular statuses for permissions than what is exposed via the W3C Permissions API. This mapping defines how the internal PermissionAccessStatus values are exposed via the fake Permissions API's PermissionState values.
For example, some browsers support allowing one-time access to a
permission. This usually results in the PermissionState remaining
as "prompt"
even after access has been allowed
or denied. In order to emulate this behavior, the default behavior of this
library is to use a mask that maps both
"ALLOWED"
and
"DENIED"
to
"prompt"
.
If no explicit mappings are provided, the default mapping is:
PermissionAccessStatus | PermissionState |
---|---|
"PROMPT" |
"prompt" |
"GRANTED" |
"granted" |
"BLOCKED" |
"denied" |
"BLOCKED_AUTOMATICALLY" |
"denied" |
"ALLOWED" |
"prompt" |
"DENIED" |
"prompt" |
A permission store.
Create a store for managing permission access.