import { registerBackendCallback } from "@itwin/certa/lib/utils/CallbackUtils" ; import { getTokenCallbackName } from "./certaCommon" ; import { IModelHost } from "@itwin/core-backend" ; import { TestUtility } from "@itwin/oidc-signin-tool/lib/cjs/" ; import { ElectronMainAuthorization } from "@itwin/electron-authorization/lib/cjs/ElectronMain" ; import { AccessToken } from "@itwin/core-bentley" ; export function exposeBackendCallbacks ( ) { registerBackendCallback ( getTokenCallbackName , async ( user ) : Promise < AccessToken > => { const testAuthClient = TestUtility . getAuthorizationClient ( user , { clientId : process . env . IMJS_OIDC_ELECTRON_TEST_CLIENT_ID ?? "" , redirectUri : process . env . IMJS_OIDC_ELECTRON_TEST_REDIRECT_URI ?? "" , scope : process . env . IMJS_OIDC_ELECTRON_TEST_SCOPES ?? "" } ) ; const accessToken = await testAuthClient . getAccessToken ( ) ; ( IModelHost . authorizationClient as ElectronMainAuthorization ) . setAccessToken ( accessToken ) ; return accessToken ; } ) ; }