import { getPath , isHierarchical , parseUri } from './uri' ; export type DataValidator = ( data ? : any ) => boolean ; export function isUndefined ( value ? ) { return typeof value === 'undefined' ; } export function isObject ( value ? ) { return ! ! value && typeof value === 'object' ; } export function isNonEmptyString ( value ? ) { return typeof value === 'string' && value . length > 0 ; } export function isBoolean ( value ? ) { return typeof value === 'boolean' ; } export function isWebUrl ( value ? ) { if ( ! isNonEmptyString ( value ) ) { return false ; } let uri = parseUri ( value ) ; if ( ! uri || ( uri . scheme !== 'http' && uri . scheme !== 'https' ) || ! uri . hierPart . startsWith ( '//' ) ) { return false ; } return ! ! uri ; } /**
 * Checks that the provided value is of form "scheme://authority", specifically
 * such that it is an absolute, hierarchical URI with no path, query or
 * fragment.
 */ export function isSchemeAndAuthorityOnlyUrl ( value ) { if ( ! isNonEmptyString ( value ) ) { return false ; } let uri = parseUri ( value ) ; if ( ! uri || uri . query || uri . fragment || ! isHierarchical ( uri ) || getPath ( uri ) ) { return false ; } return true ; } export function isValidCredential ( value ) { if ( ! isObject ( value ) || ! isNonEmptyString ( value [ 'id' ] ) || ! isSchemeAndAuthorityOnlyUrl ( value [ 'authMethod' ] ) ) { return false ; } if ( 'authDomain' in value && ! isSchemeAndAuthorityOnlyUrl ( value [ 'authDomain' ] ) ) { return false ; } if ( 'password' in value && ! isNonEmptyString ( value [ 'password' ] ) ) { return false ; } if ( 'displayName' in value && ! isNonEmptyString ( value [ 'displayName' ] ) ) { return false ; } if ( 'profilePicture' in value && ! isWebUrl ( value [ 'profilePicture' ] ) ) { return false ; } if ( 'exchangeToken' in value && ! isNonEmptyString ( value [ 'exchangeToken' ] ) ) { return false ; } if ( 'idToken' in value && ! isNonEmptyString ( value [ 'idToken' ] ) ) { return false ; } if ( 'generatedPassword' in value && ! isNonEmptyString ( value [ 'generatedPassword' ] ) ) { return false ; } if ( 'proxiedAuthRequired' in value && ! isBoolean ( value [ 'proxiedAuthRequired' ] ) ) { return false ; } return true ; } export function isValidRequestOptions ( value ) { return true ; } export function isValidHintOptions ( value ) { return true ; } export function isValidProxyLoginResponse ( value ) { return true ; } export function isValidError ( value ) { return true ; } export function isValidDisplayOptions ( value ) { return true ; }