import { AccessToken , BeEvent } from "@itwin/core-bentley" ; import { getAccessTokenFromBackend } from "@itwin/oidc-signin-tool/lib/cjs/frontend" ; import { AuthorizationClient } from "@itwin/core-common" ; export class IModelHubUserMgr implements AuthorizationClient { private _token : AccessToken = "" ; public constructor ( private _userCredentials ) { } public async signIn ( ) { this . _token = await getAccessTokenFromBackend ( this . _userCredentials ) ; this . onAccessTokenChanged . raiseEvent ( this . _token ) ; } public async signOut ( ) { this . _token = "" ; this . onAccessTokenChanged . raiseEvent ( this . _token ) ; } public readonly onAccessTokenChanged = new BeEvent < ( token : AccessToken ) => void > ( ) ; public get isAuthorized ( ) : boolean { return this . _token !== "" ; } public get hasExpired ( ) : boolean { return false ; } public get hasSignedIn ( ) : boolean { return this . _token !== "" ; } public async getAccessToken ( ) { return this . _token ; } }