Преглед на файлове

feat: dynamically load @azure/msal-browser

Shirasawa преди 3 седмици
родител
ревизия
a341b9a4ea
променени са 1 файла, в които са добавени 6 реда и са изтрити 4 реда
  1. 6 4
      src/lib/utils/onedrive-file-picker.ts

+ 6 - 4
src/lib/utils/onedrive-file-picker.ts

@@ -1,5 +1,4 @@
-import { PublicClientApplication } from '@azure/msal-browser';
-import type { PopupRequest } from '@azure/msal-browser';
+import type { PopupRequest, PublicClientApplication } from '@azure/msal-browser';
 import { v4 as uuidv4 } from 'uuid';
 import { v4 as uuidv4 } from 'uuid';
 
 
 class OneDriveConfig {
 class OneDriveConfig {
@@ -77,6 +76,7 @@ class OneDriveConfig {
 				}
 				}
 			};
 			};
 
 
+			const { PublicClientApplication } = await import('@azure/msal-browser');
 			this.msalInstance = new PublicClientApplication(msalParams);
 			this.msalInstance = new PublicClientApplication(msalParams);
 			if (this.msalInstance.initialize) {
 			if (this.msalInstance.initialize) {
 				await this.msalInstance.initialize();
 				await this.msalInstance.initialize();
@@ -136,7 +136,7 @@ async function getToken(
 		const msalInstance = await config.getMsalInstance(authorityType);
 		const msalInstance = await config.getMsalInstance(authorityType);
 		const resp = await msalInstance.acquireTokenSilent(authParams);
 		const resp = await msalInstance.acquireTokenSilent(authParams);
 		accessToken = resp.accessToken;
 		accessToken = resp.accessToken;
-	} catch (err) {
+	} catch {
 		const msalInstance = await config.getMsalInstance(authorityType);
 		const msalInstance = await config.getMsalInstance(authorityType);
 		try {
 		try {
 			const resp = await msalInstance.loginPopup(authParams);
 			const resp = await msalInstance.loginPopup(authParams);
@@ -179,6 +179,7 @@ interface PickerParams {
 interface PickerResult {
 interface PickerResult {
 	command?: string;
 	command?: string;
 	items?: OneDriveFileInfo[];
 	items?: OneDriveFileInfo[];
+	// eslint-disable-next-line @typescript-eslint/no-explicit-any
 	[key: string]: any;
 	[key: string]: any;
 }
 }
 
 
@@ -221,6 +222,7 @@ interface OneDriveFileInfo {
 		driveId: string;
 		driveId: string;
 	};
 	};
 	'@sharePoint.endpoint': string;
 	'@sharePoint.endpoint': string;
+	// eslint-disable-next-line @typescript-eslint/no-explicit-any
 	[key: string]: any;
 	[key: string]: any;
 }
 }
 
 
@@ -319,7 +321,7 @@ export async function openOneDrivePicker(
 								} else {
 								} else {
 									throw new Error('Could not retrieve auth token');
 									throw new Error('Could not retrieve auth token');
 								}
 								}
-							} catch (err) {
+							} catch {
 								channelPort?.postMessage({
 								channelPort?.postMessage({
 									type: 'result',
 									type: 'result',
 									id: portData.id,
 									id: portData.id,