import { AccessToken , BeEvent } from "@itwin/core-bentley" ; import { AuthorizationClient } from "@itwin/core-common" ; packageDocumentation module internal export function tokenFromUserCredentials ( userCredentials ) { const tokenString = Buffer . from ( `${ userCredentials . email }:${ userCredentials . password }` ) . toString ( "base64" ) ; return tokenString ; } internal export class IModelBankBasicAuthorizationClient implements AuthorizationClient { private _token : AccessToken = "" ; public constructor ( private _userCredentials ) { } public async signIn ( ) { this . _token = tokenFromUserCredentials ( 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 ! this . _token ; } public get hasSignedIn ( ) : boolean { return this . _token !== "" ; } public async getAccessToken ( ) { return this . _token ; } }