Skip to content

Window is not defined #307

Closed
Closed
@Akxe

Description

@Akxe

Bug Report
Prerequisites

Can you reproduce the problem?
Are you running the latest version?
Are you reporting to the correct repository?
Did you perform a cursory search?

For more information, see the CONTRIBUTING guide.
Description
Error when following steps in the readme.
Console Errors:
C:\Users\akxe\Documents\Programming\rita\node_modules\msal\src\cache\BrowserStorage.ts:18
if (!window) {
^
ReferenceError: window is not defined
at AuthCache.BrowserStorage (C:\Users\akxe\Documents\Programming\rita\node_modules\msal\src\cache\BrowserStorage.ts:18:9)
at new AuthCache (C:\Users\akxe\Documents\Programming\rita\node_modules\msal\src\cache\AuthCache.ts:22:9)
at new UserAgentApplication (C:\Users\akxe\Documents\Programming\rita\node_modules\msal\src\UserAgentApplication.ts:230:29)
at Module../apps/server/src/mail-adapter/microsoft/provider.ts (C:\Users\akxe\Documents\Programming\rita\dist\apps\server\webpack:\apps\server\src\mail-adapter\microsoft\provider.ts:17:2)
at webpack_require (C:\Users\akxe\Documents\Programming\rita\dist\apps\server\webpack:\webpack\bootstrap:19:1)
at Module../apps/server/src/main.ts (C:\Users\akxe\Documents\Programming\rita\dist\apps\server\main.js:518:90)
at webpack_require (C:\Users\akxe\Documents\Programming\rita\dist\apps\server\webpack:\webpack\bootstrap:19:1)
at Object.0 (C:\Users\akxe\Documents\Programming\rita\dist\apps\server\main.js:1133:18)
at webpack_require (C:\Users\akxe\Documents\Programming\rita\dist\apps\server\webpack:\webpack\bootstrap:19:1)
at C:\Users\akxe\Documents\Programming\rita\dist\apps\server\webpack:\webpack\bootstrap:83:1

Screenshots: Not needed
Steps to Reproduce
Create in NodeJS environment:
const authProvider = new ImplicitMSALAuthenticationProvider(
new UserAgentApplication( {
auth: {
clientId: process.env.MICROSOFT_ID!, // Client Id of the registered application
redirectUri: process.env.MICROSOFT_SECRET!,
},
}),
new MSALAuthenticationProviderOptions(process.env.MICROSOFT_SCOPES!.split(' ')),
);

const client = Client.initWithMiddleware({ authProvider });
Expected behavior: No error when following readme
Actual behavior: Error...

Maybe use globalThis to check?
Additional Context
I am transpiling from TS to JS.
Usage Information
SDK Version - [SDK version you are using]

Node (Check, if using Node version of SDK)

Node Version - v14.4.0

Browser (Check, if using Browser version of SDK)

Browser Name - ---

Version - ---
AB#5598

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions