Home Reference Source
public class | source

SalteAuthUtilities

Basic utilities to support the authentication flow

Constructor Summary

Public Constructor
public

constructor(config: Config)

Wraps all XHR and Fetch (if available) requests to allow promise interceptors

Method Summary

Public Methods
public

Adds a fetch interceptor

public

addXHRInterceptor(interceptor: Function)

Adds a XMLHttpRequest interceptor

public

Checks if the given url matches any of the test urls

public

createIframe(url: String, show: Boolean, timeout: Number): Promise

Opens an iframe in the background

public

createUrl(baseUrl: String, queryParams: Object): String

Creates a URL using a base url and a queryParams object

public

isRouteSecure(route: String, securedRoutes: Boolean | Array<String>): Boolean

Determines if the given route is a secured route

public

Opens a new tab

public

openPopup(url: String, name: String, height: Number, width: Number): Promise

Opens a popup window in the middle of the viewport

public

Converts a url to an absolute url

Public Constructors

public constructor(config: Config) source

Wraps all XHR and Fetch (if available) requests to allow promise interceptors

Params:

NameTypeAttributeDescription
config Config

configuration for salte auth

Public Methods

public addFetchInterceptor(interceptor: Function) source

Adds a fetch interceptor

Params:

NameTypeAttributeDescription
interceptor Function

the interceptor function

public addXHRInterceptor(interceptor: Function) source

Adds a XMLHttpRequest interceptor

Params:

NameTypeAttributeDescription
interceptor Function

the interceptor function

public checkForMatchingUrl(url: String, tests: Array<String|RegExp>): Boolean source

Checks if the given url matches any of the test urls

Params:

NameTypeAttributeDescription
url String

The url to test

tests Array<String|RegExp>

The urls to match the test url against

Return:

Boolean

true if the url matches one of the tests

public createIframe(url: String, show: Boolean, timeout: Number): Promise source

Opens an iframe in the background

Params:

NameTypeAttributeDescription
url String

the url to be loaded

show Boolean

whether the iframe should be visible

timeout Number

duration to wait before rejecting the request

Return:

Promise

resolves when the iframe is closed

public createUrl(baseUrl: String, queryParams: Object): String source

Creates a URL using a base url and a queryParams object

Params:

NameTypeAttributeDescription
baseUrl String

the base url to attach the queryParams to

queryParams Object

the queryParams to attach to the baseUrl

Return:

String

the url with the request queryParams

public isRouteSecure(route: String, securedRoutes: Boolean | Array<String>): Boolean source

Determines if the given route is a secured route

Params:

NameTypeAttributeDescription
route String

the route to verify

securedRoutes Boolean | Array<String>

a list of routes that require authentication

Return:

Boolean

true if the route provided is a secured route

public openNewTab(url: String): Promise source

Opens a new tab

Params:

NameTypeAttributeDescription
url String

the url to be loaded

Return:

Promise

resolves when the tab is closed

public openPopup(url: String, name: String, height: Number, width: Number): Promise source

Opens a popup window in the middle of the viewport

Params:

NameTypeAttributeDescription
url String

the url to be loaded

name String

the name of the window

height Number

the height of the window

width Number

the width of the window

Return:

Promise

resolves when the popup is closed

public resolveUrl(path: String): String source

Converts a url to an absolute url

Params:

NameTypeAttributeDescription
path String

the url path to resolve to an absolute url

Return:

String

the absolutely resolved url