/**
 * -------------------------------------------------------------------------------------------
 * Copyright (c) Microsoft Corporation.  All Rights Reserved.  Licensed under the MIT License.
 * See License in the project root for license information.
 * -------------------------------------------------------------------------------------------
 */ import { IProvider , ProviderState , createFromProvider } from '@microsoft/mgt-element' ; interface declare interface AadTokenProvider { param { string } x memberof getToken ( x ) ; } export interface declare interface WebPartContext { aadTokenProviderFactory : any ; } export class extends IProvider export class SharePointProvider extends IProvider { readonly memberof get provider ( ) { return this . _provider ; } readonly type { boolean } memberof get isLoggedIn ( ) : boolean { return ! ! this . _idToken ; } readonly memberof public get name ( ) { return 'MgtSharePointProvider' ; } type { string [ ] } memberof public scopes : string [ ] ; type { string } memberof public authority : string ; private _idToken : string ; private _provider : AadTokenProvider ; constructor ( context ) { super ( ) ; context . aadTokenProviderFactory . getTokenProvider ( ) . then ( ( tokenProvider ) : void => { this . _provider = tokenProvider ; this . graph = createFromProvider ( this ) ; this . internalLogin ( ) ; } ) ; } returns { Promise < string > } memberof public async getAccessToken ( ) { let accessToken ; try { accessToken = await this . provider . getToken ( 'https://graph.microsoft.com' ) ; } catch ( e ) { throw e ; } return accessToken ; } param { string [ ] } scopes memberof public updateScopes ( scopes ) { this . scopes = scopes ; } private async internalLogin ( ) { this . _idToken = await this . getAccessToken ( ) ; this . setState ( this . _idToken ? ProviderState . SignedIn : ProviderState . SignedOut ) ; } }