ScopeSet class
The ScopeSet class creates a set of scopes. Scopes are case-insensitive, unique values, so the Set object in JS makes the most sense to implement for this class. All scopes are trimmed and converted to lower case strings in intersection and union functions to ensure uniqueness of strings.
Constructors
| Scope |
Methods
| append |
Appends single scope if passed |
| append |
Appends multiple scopes if passed |
| as |
Returns the scopes as an array of string values |
| contains |
Check if set of scopes contains only the defaults |
| contains |
Check if a given scope is present in this set of scopes. |
| contains |
Check if a set of scopes is present in this set of scopes. |
| create |
Creates the set of scopes to search for in cache lookups |
| from |
Factory method to create ScopeSet from space-delimited string |
| get |
Returns size of set of scopes. |
| intersecting |
Check if scopes intersect between this set and another. |
| print |
Prints scopes into a space-delimited string |
| print |
Prints scopes into a space-delimited lower-case string (used for caching) |
| remove |
Removes default scopes from set of scopes Primarily used to prevent cache misses if the default scopes are not returned from the server |
| remove |
Removes element from set of scopes. |
| union |
Combines an array of scopes with the current set of scopes. |
Constructor Details
ScopeSet(string[])
new ScopeSet(inputScopes: string[])
Parameters
- inputScopes
-
string[]
Method Details
appendScope(string)
Appends single scope if passed
function appendScope(newScope: string)
Parameters
- newScope
-
string
appendScopes(string[])
Appends multiple scopes if passed
function appendScopes(newScopes: string[])
Parameters
- newScopes
-
string[]
asArray()
Returns the scopes as an array of string values
function asArray(): string[]
Returns
string[]
containsOnlyOIDCScopes()
Check if set of scopes contains only the defaults
function containsOnlyOIDCScopes(): boolean
Returns
boolean
containsScope(string)
Check if a given scope is present in this set of scopes.
function containsScope(scope: string): boolean
Parameters
- scope
-
string
Returns
boolean
containsScopeSet(ScopeSet)
Check if a set of scopes is present in this set of scopes.
function containsScopeSet(scopeSet: ScopeSet): boolean
Parameters
- scopeSet
- ScopeSet
Returns
boolean
createSearchScopes(string[])
Creates the set of scopes to search for in cache lookups
static function createSearchScopes(inputScopeString: string[]): ScopeSet
Parameters
- inputScopeString
-
string[]
Returns
fromString(string)
Factory method to create ScopeSet from space-delimited string
static function fromString(inputScopeString: string): ScopeSet
Parameters
- inputScopeString
-
string
Returns
getScopeCount()
Returns size of set of scopes.
function getScopeCount(): number
Returns
number
intersectingScopeSets(ScopeSet)
Check if scopes intersect between this set and another.
function intersectingScopeSets(otherScopes: ScopeSet): boolean
Parameters
- otherScopes
- ScopeSet
Returns
boolean
printScopes()
Prints scopes into a space-delimited string
function printScopes(): string
Returns
string
printScopesLowerCase()
Prints scopes into a space-delimited lower-case string (used for caching)
function printScopesLowerCase(): string
Returns
string
removeOIDCScopes()
Removes default scopes from set of scopes Primarily used to prevent cache misses if the default scopes are not returned from the server
function removeOIDCScopes()
removeScope(string)
Removes element from set of scopes.
function removeScope(scope: string)
Parameters
- scope
-
string
unionScopeSets(ScopeSet)
Combines an array of scopes with the current set of scopes.
function unionScopeSets(otherScopes: ScopeSet): Set<string>
Parameters
- otherScopes
- ScopeSet
Returns
Set<string>