import { OAuthProvider } from './provider' ; import { utils } from './utility' ; export class Oauth { defaultWindowOptions : Object = { } ; login ( provider , windowOptions = { } ) { console . warn ( `
        new CordovaOauth().login(...) is deprecated and will be removed in the next release.
        Please use new CordovaOauth().logInVia(...) instead.
      ` ) ; return this . logInVia ( provider , windowOptions ) ; } logInVia ( provider , windowOptions = { } ) { const url = provider . dialogUrl ( ) ; return this . openDialog ( url , utils . defaults ( windowOptions , this . defaultWindowOptions ) , { resolveOnUri : provider . options . redirectUri , providerName : provider . name } ) . then ( ( event ) => { return provider . parseResponseInUrl ( event . url ) ; } ) ; } protected serializeOptions ( options ) { const chunks = [ ] ; for ( const prop in options ) { if ( options . hasOwnProperty ( prop ) ) { chunks . push ( `${ prop }=${ options [ prop ] }` ) ; } } return chunks . join ( ',' ) ; } protected openDialog ( url , windowParams , options = { } ) { return Promise . reject ( new Error ( 'Not implemented' ) ) ; } } export interface IOauthProvider { parseResponseInUrl ( url ) : Object ; }