Skip to content

Commit

Permalink
Bump typescript to 4.9.5 and build target to es2020 (#5750)
Browse files Browse the repository at this point in the history
- Bump `typescript` to 4.9.5.
- Bump target/module versions to `es2020` when applicable.
- Replace calls to deprecated `mocked()` from `ts-jest/utils` with
`jest.spyOn()`.
- Fix types' coercions to facilitate compatibility with the new ts
version.
- Make generic type extend `ServerAuthorizationTokenResponse` for
`NetworkManager.sendPostRequest()` in `msal-common` to handle post
processing properly.
- Make `serverTelemetryManager.cacheFailedRequest()` accept any types of
errors.
  • Loading branch information
konstantin-msft committed Mar 31, 2023
1 parent 081f402 commit 6700c99
Show file tree
Hide file tree
Showing 59 changed files with 551 additions and 434 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Bump typescript version to 4.9.5 #5750",
"packageName": "@azure/msal-node-extensions",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"comment": "Bump typescript to 4.9.5 and build target to es2020 #5750",
"type": "none",
"packageName": "@azure/node-token-validation",
"email": "[email protected]",
"dependentChangeType": "none"
}
7 changes: 7 additions & 0 deletions change/msal-1a69cf50-db5e-4aaf-ab86-32f98e28bec4.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "minor",
"comment": "Bump typescript to 4.9.5 and build target to es2020 #5750",
"packageName": "msal",
"email": "[email protected]",
"dependentChangeType": "patch"
}
159 changes: 89 additions & 70 deletions extensions/msal-node-extensions/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion extensions/msal-node-extensions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@
"husky": "^4.2.5",
"tsdx": "^0.14.1",
"tslib": "^2.0.0",
"typescript": "^3.9.3"
"typescript": "^4.9.5"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import { DataProtectionScope, FilePersistenceWithDataProtection } from "../../src";
import { FileSystemUtils } from "../util/FileSystemUtils";
import { Dpapi } from "../../src/Dpapi";
import { mocked } from 'ts-jest/utils';

jest.mock("../../src/Dpapi");

Expand Down Expand Up @@ -34,8 +33,8 @@ describe('Test File Persistence with data protection', () => {
});

test('Saves and loads contents', async () => {
mocked(Dpapi.unprotectData).mockReturnValueOnce(Buffer.from("data"));
mocked(Dpapi.protectData).mockReturnValueOnce(Buffer.from("encryptedData"));
jest.spyOn(Dpapi, 'unprotectData').mockReturnValueOnce(Buffer.from("data"));
jest.spyOn(Dpapi, 'protectData').mockReturnValueOnce(Buffer.from("encryptedData"));

const persistence = await FilePersistenceWithDataProtection.create(filePath, dpapiScope);
const contents = "test";
Expand Down
1 change: 1 addition & 0 deletions extensions/msal-node-extensions/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"include": ["src", "test"],
"compilerOptions": {
"module": "esnext",
"target": "es2020",
"moduleResolution": "node",
"lib": ["dom", "esnext"],
"importHelpers": true,
Expand Down
11 changes: 7 additions & 4 deletions lib/msal-browser/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/msal-browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"ts-jest": "^27.0.2",
"tslib": "^1.10.0",
"tslint": "^5.20.0",
"typescript": "^3.8.3"
"typescript": "^4.9.5"
},
"dependencies": {
"@azure/msal-common": "^10.0.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ export class NativeMessageHandler {
// Do nothing if method is not Response or HandshakeResponse
} catch (err) {
this.logger.error("Error parsing response from WAM Extension");
this.logger.errorPii(`Error parsing response from WAM Extension: ${err.toString()}`);
this.logger.errorPii(`Error parsing response from WAM Extension: ${err as string}`);
this.logger.errorPii(`Unable to parse ${event}`);

if (resolver) {
Expand Down
4 changes: 2 additions & 2 deletions lib/msal-browser/src/cache/BrowserCacheManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class BrowserCacheManager extends CacheManager {
// Temporary cache items will always be stored in session storage to mitigate problems caused by multiple tabs
return new BrowserStorage(cacheLocation);
} catch (e) {
this.logger.verbose(e);
this.logger.verbose(e as string);
break;
}
case BrowserCacheLocation.MemoryStorage:
Expand All @@ -84,7 +84,7 @@ export class BrowserCacheManager extends CacheManager {
// Temporary cache items will always be stored in session storage to mitigate problems caused by multiple tabs
return new BrowserStorage(BrowserCacheLocation.SessionStorage);
} catch (e) {
this.logger.verbose(e);
this.logger.verbose(e as string);
return this.internalStorage;
}
case BrowserCacheLocation.MemoryStorage:
Expand Down
10 changes: 5 additions & 5 deletions lib/msal-browser/src/controllers/StandardController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { BrowserUtils } from "../utils/BrowserUtils";
import { RedirectRequest } from "../request/RedirectRequest";
import { PopupRequest } from "../request/PopupRequest";
import { SsoSilentRequest } from "../request/SsoSilentRequest";
import { EventCallbackFunction } from "../event/EventMessage";
import { EventCallbackFunction, EventError } from "../event/EventMessage";
import { EventType } from "../event/EventType";
import { EndSessionRequest } from "../request/EndSessionRequest";
import { BrowserConfigurationAuthError } from "../error/BrowserConfigurationAuthError";
Expand Down Expand Up @@ -209,7 +209,7 @@ export class StandardController implements IController {
try {
this.nativeExtensionProvider = await NativeMessageHandler.createProvider(this.logger, this.config.system.nativeBrokerHandshakeTimeout, this.performanceClient);
} catch (e) {
this.logger.verbose(e);
this.logger.verbose(e as string);
}
}
this.initialized = true;
Expand Down Expand Up @@ -277,9 +277,9 @@ export class StandardController implements IController {
}).catch((e) => {
// Emit login event if there is an account
if (loggedInAccounts.length > 0) {
this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_FAILURE, InteractionType.Redirect, null, e);
this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_FAILURE, InteractionType.Redirect, null, e as EventError);
} else {
this.eventHandler.emitEvent(EventType.LOGIN_FAILURE, InteractionType.Redirect, null, e);
this.eventHandler.emitEvent(EventType.LOGIN_FAILURE, InteractionType.Redirect, null, e as EventError);
}
this.eventHandler.emitEvent(EventType.HANDLE_REDIRECT_END, InteractionType.Redirect);

Expand Down Expand Up @@ -618,7 +618,7 @@ export class StandardController implements IController {
}

} catch (e) {
this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_BY_CODE_FAILURE, InteractionType.Silent, null, e);
this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_BY_CODE_FAILURE, InteractionType.Silent, null, e as EventError);
atbcMeasurement.endMeasurement({
errorCode: e instanceof AuthError && e.errorCode || undefined,
subErrorCode: e instanceof AuthError && e.subError || undefined,
Expand Down
Loading

0 comments on commit 6700c99

Please sign in to comment.