File tree Expand file tree Collapse file tree 3 files changed +40
-29
lines changed
Expand file tree Collapse file tree 3 files changed +40
-29
lines changed Original file line number Diff line number Diff line change 11export class PublicClientApplication {
2- constructor(configuration: any) {
3- // Mock constructor
4- }
2+ constructor(configuration: any) {
3+ // Mock constructor
4+ }
55
6- initialize() {
7- // Mock initialize method
8- }
6+ async initialize() {
7+ // Mock implementation of initialize
8+ return Promise.resolve();
9+ }
910
10- acquireTokenSilent() {
11- // Mock acquireTokenSilent method
12- return Promise.resolve({ accessToken: 'mock-access-token' });
13- }
11+ acquireTokenSilent() {
12+ // Mock acquireTokenSilent method
13+ return Promise.resolve({ accessToken: 'mock-access-token' });
14+ }
1415
15- acquireTokenPopup() {
16- // Mock acquireTokenPopup method
17- return Promise.resolve({ accessToken: 'mock-access-token' });
18- }
16+ acquireTokenPopup() {
17+ // Mock acquireTokenPopup method
18+ return Promise.resolve({ accessToken: 'mock-access-token' });
19+ }
1920
20- loginPopup() {
21- // Mock loginPopup method
22- return Promise.resolve({ account: { username: 'mock-user' } });
23- }
21+ loginPopup() {
22+ // Mock loginPopup method
23+ return Promise.resolve({ account: { username: 'mock-user' } });
24+ }
2425
25- logout() {
26- // Mock logout method
27- return Promise.resolve();
28- }
29- }
26+ logout() {
27+ // Mock logout method
28+ return Promise.resolve();
29+ }
30+ }
Original file line number Diff line number Diff line change @@ -33,10 +33,12 @@ import { IDevxAPI } from './types/devx-api';
3333import { Mode } from './types/enums' ;
3434import { IHistoryItem } from './types/history' ;
3535import { Collection } from './types/resources' ;
36+ import { initializeMsal } from './modules/authentication/msal-app' ;
3637
3738
3839const appRoot : HTMLElement = document . getElementById ( 'root' ) ! ;
3940initializeIcons ( ) ;
41+ await initializeMsal ( ) ;
4042
4143let currentTheme = readFromLocalStorage ( CURRENT_THEME ) || 'light' ;
4244export function removeSpinners ( ) {
Original file line number Diff line number Diff line change @@ -68,10 +68,18 @@ export const configuration: Configuration = {
6868 }
6969} ;
7070
71- const initializeMsal = async ( ) : Promise < void > => {
72- await msalApplication . initialize ( ) ;
73- } ;
71+ export const msalApplication = new PublicClientApplication ( configuration ) ;
7472
75- const msalApplication = new PublicClientApplication ( configuration ) ;
76- await initializeMsal ( ) ;
77- export { msalApplication } ;
73+ export async function initializeMsal ( ) : Promise < void > {
74+ try {
75+ await msalApplication . initialize ( ) ;
76+ return Promise . resolve ( ) ;
77+ } catch ( error ) {
78+ telemetry . trackException (
79+ new Error ( errorTypes . OPERATIONAL_ERROR ) ,
80+ SeverityLevel . Error ,
81+ { ComponentName : 'MSAL' , Message : 'Failed to initialize MSAL' }
82+ ) ;
83+ return Promise . reject ( error ) ;
84+ }
85+ }
You can’t perform that action at this time.
0 commit comments