@trimble-oss/trimble-id-react
Version:
> **Important Notice:** > > As of version 1.0.0, `PersistentOptions` have been removed. By default, the SDK now supports in-memory token storage. > > When you upgrade to version 1.x, storage options will no longer be available, resulting in a breaking
62 lines (61 loc) • 2.71 kB
TypeScript
import { TIDJWTUser, TIDUser } from './interfaces';
/**
* Remove the search params from the url
* @param {string} url - Url to remove the search params
* @return {string} - Url without the search params
* @example
* removeSearchParams('https://example.com/test?state=fake_state&another_prop=fake_prop')
* // will return https://example.com/test
* @example
* removeSearchParams('https://example.com/test')
* // will return https://example.com/test
* @example
* removeSearchParams('https://example.com/test?state=fake_state&another_prop=fake_prop#hash')
* // will return https://example.com/test
*/
export declare const removeSearchParams: (url: string) => string;
/**
* Extract the params from the URL.
* @param {string} url - Url to extract information
* @return {string} - Params of the url
* @example
* getQueryParams('https://example.com/test?state=fake_state&another_prop=fake_prop')
* // will return ?state=fake_state&another_prop=fake_prop
*/
export declare const getQueryParams: (url: string) => string;
/**
* Receives an url and converted into URLSearchParams
* @param {string} url - Url to extract information
* @return {URLSearchParams} - URLSearchParams containing the parameters from the URL
* @example Full url
* getSearchParams('https://example.com/test?state=fake_state&another_prop=fake_prop')
* @example Only params
* getSearchParams('?state=fake_state&another_prop=fake_prop')
*/
export declare const getSearchParams: (url: string) => URLSearchParams;
/**
* Compare if the url contains the necessary information for the authentication
*
* Note: The required parameters that the url should contain are the following:
* * code
* * state
* * identity_provider
* @param redirectUrl - If the redirect url is provided, it will check if the url starts with the redirect url provided. If not, it will return false
* @param {string} url - Url to determined if it has the requirement auth params. By default, takes the url of the browser
* @return {boolean} - True or false if the url is valid
* @example No url
* hasAuthParams() // This will take the url from the browser
* @example Valid url
* getSearchParams('https://example.com/test?code=fake_code&state=fake_state')
* // return true
* @example Invalid url
* getSearchParams('https://example.com/test?code=fake_code')
* // return true
*/
export declare const hasAuthParams: (url?: string, redirectUrl?: string) => boolean;
/**
* Converts the raw JWT user returned from TID and converted into a TIDUser
* @param {TIDJWTUser} jwtUser - TIDJWTUser to convert
* @return {TIDUser} - TIDJWTUser converted into a TIDUser
*/
export declare const transformToTIDUser: (jwtUser: TIDJWTUser) => TIDUser;