Skip to content

Commit 90e7f01

Browse files
Merge remote-tracking branch 'origin/enable_1p_naa' into enable_1p_naa
2 parents 78a21ac + ad542fc commit 90e7f01

File tree

30 files changed

+2652
-350
lines changed

30 files changed

+2652
-350
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "minor",
3+
"comment": "Minify logging strings with rollup plugin #8000",
4+
"packageName": "@azure/msal-browser",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "major",
3+
"comment": "Remove onRedirectNavigate from endSessionRequest #8066",
4+
"packageName": "@azure/msal-browser",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "minor",
3+
"comment": "Minify logging strings with rollup plugin #8000",
4+
"packageName": "@azure/msal-common",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}

lib/msal-browser/apiReview/msal-browser.api.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,6 @@ export type EndSessionPopupRequest = Partial<Omit<CommonEndSessionRequest, "toke
563563
// @public
564564
export type EndSessionRequest = Partial<Omit<CommonEndSessionRequest, "tokenQueryParameters">> & {
565565
authority?: string;
566-
onRedirectNavigate?: (url: string) => boolean | void;
567566
};
568567

569568
// Warning: (ae-missing-release-tag) "EventCallbackFunction" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)

lib/msal-browser/docs/logout.md

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,25 @@ await msalInstance.logoutRedirect({
6060
```
6161

6262
### Skipping the server sign-out
63-
6463
**WARNING:** Skipping the server sign-out means the user's session will remain active on the server and can be signed back into your application without providing credentials again.
6564

66-
If you want your application to only perform local logout you can provide a callback to the `onRedirectNavigate` parameter on the request and have the callback return false.
65+
If you want your application to only perform local logout you can provide a callback to the `onRedirectNavigate` parameter in the configuration and have the callback return false.
6766

6867
```javascript
69-
msalInstance.logoutRedirect({
70-
onRedirectNavigate: (url) => {
71-
// Return false if you would like to stop navigation after local logout
72-
return false;
68+
const msalConfig = {
69+
auth: {
70+
clientId: 'your_client_id',
71+
authority: 'https://login.microsoftonline.con/{your_tenant_id}',
72+
redirectUri: 'https://contoso.com',
73+
postLogoutRedirectUri: 'https://contoso.com/homepage',
74+
onRedirectNavigate: (url) => {
75+
// Return false if you would like to stop navigation after local logout
76+
return false;
77+
}
7378
}
74-
});
79+
};
80+
const msalInstance = new PublicClientApplication(msalConfig);
81+
msalInstance.logoutRedirect();
7582
```
7683

7784
## logoutPopup
@@ -151,30 +158,26 @@ Example:
151158
```typescript
152159
const msal = new PublicClientApplication({
153160
auth: {
154-
clientId: "my-client-id"
161+
clientId: "my-client-id",
162+
onRedirectNavigate: (url) => {
163+
return false;
164+
}
155165
},
156166
system: {
157167
allowRedirectInIframe: true
158168
}
159169
})
160170

161171
// Automatically on page load
162-
msal.logoutRedirect({
163-
onRedirectNavigate: () => {
164-
// Return false to stop navigation after local logout
165-
return false;
166-
}
167-
});
172+
msal.logoutRedirect();
168173
```
169174

170-
Now when a user logouts out of another application, your application's front-channel logout url will be loaded in a hidden iframe, and MSAL.js will clear its cache to complete single-sign out.
171-
175+
Please note that front-channel logout is not always supported across browsers. Chromium enabled [Storage Partitioning](https://privacysandbox.google.com/cookies/storage-partitioning) and Firefox supports [similar standard](https://developer.mozilla.org/en-US/docs/Web/Privacy/Guides/State_Partitioning) limiting applications to execute front-channel logout. For official Entra documentation on this topic, see [here](https://learn.microsoft.com/en-us/entra/identity-platform/reference-third-party-cookies-spas#limitations-on-front-channel-logout-without-third-party-cookies).
172176

173177
### Front-channel logout samples
174178

175179
The following samples demonstrate how to implement front-channel logout using MSAL.js:
176180

177-
- MSAL Angular v2: [Angular 11 sample](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/samples/msal-angular-v2-samples/angular11-sample-app)
178181
- MSAL React: [React Router sample](https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/samples/msal-react-samples/react-router-sample)
179182

180183
## Events

lib/msal-browser/docs/v4-migration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ See the [Configuration doc](./configuration.md#system-config-options) for more d
159159

160160
### Removal of `onRedirectNavigate` parameter
161161

162-
The `onRedirectNavigate` parameter has been removed from the `RedirectRequest` object. It has *not* been removed from the `Configuration` object and can continue to be set there.
162+
The `onRedirectNavigate` parameter will *only be supported* from `Configuration` object going forward and is removed from `RedirectRequest` and `EndSessionRequest` objects. Please ensure to set it in msal config if you need to use it.
163163

164164
## Behavioral Breaking Changes
165165

lib/msal-browser/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,12 @@
7272
"test:coverage": "jest --coverage",
7373
"test:coverage:only": "npm run clean:coverage && npm run test:coverage",
7474
"build:all": "cd ../.. && npm run build --workspace=@azure/msal-common --workspace=@azure/msal-browser",
75+
"build:all:debug": "cd ../.. && MSAL_MINIFY_LOGS=false npm run build --workspace=@azure/msal-common --workspace=@azure/msal-browser",
7576
"build:modules": "rollup -c --strictDeprecations --bundleConfigAsCjs",
7677
"build:modules:watch": "rollup -cw --bundleConfigAsCjs",
7778
"build": "npm run clean && npm run build:modules",
79+
"build:debug": "npm run clean && MSAL_MINIFY_LOGS=false npm run build:modules",
80+
"decode-logs": "node scripts/decode-logs.cjs",
7881
"prepack": "npm run build:all",
7982
"format:check": "prettier --ignore-path .gitignore --check src test",
8083
"format:fix": "prettier --ignore-path .gitignore --write src test",
@@ -114,4 +117,4 @@
114117
"dependencies": {
115118
"@azure/msal-common": "15.7.0"
116119
}
117-
}
120+
}

lib/msal-browser/rollup.config.js

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ import { nodeResolve } from "@rollup/plugin-node-resolve";
77
import typescript from "@rollup/plugin-typescript";
88
import terser from "@rollup/plugin-terser";
99
import pkg from "./package.json";
10-
import { createPackageJson } from "rollup-msal";
10+
import { createPackageJson, loggerMinifyPlugin } from "rollup-msal";
11+
import path from "path";
1112

1213
const libraryHeader = `/*! ${pkg.name} v${pkg.version} ${
1314
new Date().toISOString().split("T")[0]
1415
} */`;
1516
const useStrictHeader = "'use strict';";
1617
const fileHeader = `${libraryHeader}\n${useStrictHeader}`;
18+
const minifyLogs = process.env.MSAL_MINIFY_LOGS !== 'false';
1719

1820
export default [
1921
{
@@ -38,6 +40,11 @@ export default [
3840
typescript: require("typescript"),
3941
tsconfig: "tsconfig.build.json",
4042
}),
43+
...(minifyLogs === true ? [loggerMinifyPlugin({
44+
verbose: true,
45+
outputFile: path.resolve(__dirname, "./dist/log-strings-mapping.json"),
46+
packageJsonPath: path.resolve(__dirname, "./package.json"),
47+
})] : []),
4148
],
4249
},
4350
{
@@ -65,6 +72,11 @@ export default [
6572
compilerOptions: { outDir: "lib/types" },
6673
}),
6774
createPackageJson({ libPath: __dirname }),
75+
...(minifyLogs === true ? [loggerMinifyPlugin({
76+
outputFile: path.resolve(__dirname, "./lib/log-strings-mapping.json"),
77+
packageJsonPath: path.resolve(__dirname, "./package.json"),
78+
verbose: true
79+
})] : []),
6880
],
6981
},
7082
{
@@ -96,6 +108,9 @@ export default [
96108
declarationMap: false,
97109
},
98110
}),
111+
...(minifyLogs === true ? [loggerMinifyPlugin({
112+
verbose: true
113+
})] : []),
99114
],
100115
},
101116
{
@@ -127,9 +142,13 @@ export default [
127142
declarationMap: false,
128143
},
129144
}),
145+
loggerMinifyPlugin({
146+
verbose: true
147+
}),
130148
terser({
131149
output: {
132150
preamble: libraryHeader,
151+
comments: false,
133152
},
134153
}),
135154
],
@@ -156,6 +175,11 @@ export default [
156175
typescript: require("typescript"),
157176
tsconfig: "tsconfig.custom-auth.build.json",
158177
}),
178+
...(minifyLogs === true ? [loggerMinifyPlugin({
179+
verbose: true,
180+
outputFile: path.resolve(__dirname, "./dist/custom-auth-path/log-strings-mapping.json"),
181+
packageJsonPath: path.resolve(__dirname, "./package.json"),
182+
})] : []),
159183
],
160184
},
161185
{
@@ -180,6 +204,11 @@ export default [
180204
sourceMap: true,
181205
compilerOptions: { outDir: "lib/custom-auth-path/types" },
182206
}),
207+
...(minifyLogs === true ? [loggerMinifyPlugin({
208+
outputFile: path.resolve(__dirname, "./lib/custom-auth-path/log-strings-mapping.json"),
209+
packageJsonPath: path.resolve(__dirname, "./package.json"),
210+
verbose: true
211+
})] : []),
183212
],
184213
},
185214
];

lib/msal-browser/scripts/README.md

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# MSAL Browser Log Decoder
2+
3+
This script decodes hashed logging strings from browser console logs back to their original messages.
4+
5+
## Overview
6+
7+
The MSAL Browser library hashes logging strings to reduce bundle size. When running in a browser, console logs display these hashes instead of full messages. This decoder script transforms those hashed logs back into readable messages and saves them to a new file.
8+
9+
## Log Format
10+
11+
The script expects log files where each MSAL log entry follows this format:
12+
```
13+
[timestamp] : [correlation-id] : @azure/[module]@[version] : [LogLevel] - [hash]
14+
```
15+
16+
Example:
17+
```
18+
[Tue, 07 Oct 2025 16:50:29 GMT] : [] : @azure/[email protected] : Verbose - 0hoqeo
19+
[Tue, 07 Oct 2025 16:50:30 GMT] : [abc-123] : @azure/[email protected] : Info - 1atvtd
20+
```
21+
22+
Non-MSAL log lines are preserved unchanged in the output.
23+
24+
## Usage
25+
26+
### Basic Usage
27+
```bash
28+
node scripts/decode-logs.cjs <path-to-log-file>
29+
```
30+
31+
### With NPM Script
32+
```bash
33+
npm run decode-logs -- <path-to-log-file>
34+
```
35+
36+
### Verbose Mode
37+
Add `--verbose` or `-V` flag for detailed debugging information:
38+
```bash
39+
node scripts/decode-logs.cjs --verbose <path-to-log-file>
40+
npm run decode-logs -- --verbose /path/to/console.log
41+
```
42+
43+
### Examples
44+
```bash
45+
# Decode logs from a file
46+
node scripts/decode-logs.cjs ./console-logs.txt
47+
# Output: ./console-logs-decoded.txt
48+
49+
# Decode with verbose output
50+
node scripts/decode-logs.cjs --verbose /Users/user/Downloads/browser-console.log
51+
# Output: /Users/user/Downloads/browser-console-decoded.log
52+
53+
# Using npm script
54+
npm run decode-logs -- ./logs/debug.log
55+
# Output: ./logs/debug-decoded.log
56+
```
57+
58+
## Output
59+
60+
The script creates a new file with the decoded logs in the same directory as the input file, adding a `-decoded` suffix before the file extension:
61+
62+
- Input: `/path/to/debug.log` → Output: `/path/to/debug-decoded.log`
63+
64+
## Features
65+
66+
- **Automatic Version Detection**: Extracts module@version from each log entry and fetches appropriate mappings
67+
- **Multi-Module Support**: Handles logs from multiple MSAL packages (msal-browser, msal-common, etc.)
68+
- **Multiple Versions Support**: Can handle multiple versions of the same module in a single file
69+
- **Efficient Mapping Download**: Downloads each unique module@version combination only once
70+
- **Local Fallback**: Automatically falls back to local mapping files when remote fetching fails
71+
- **Non-MSAL Log Preservation**: Leaves non-MSAL log lines unchanged
72+
- **File Output**: Saves decoded logs to a new file with `-decoded` suffix
73+
- **Remote Mapping Fetching**: Automatically downloads mappings from npm registry
74+
- **Caching**: Caches downloaded mappings for 24 hours to improve performance
75+
- **Verbose Mode**: Detailed debugging information with `--verbose` flag
76+
77+
## How It Works
78+
79+
1. **Scans the entire log file** to identify all unique module@version combinations
80+
2. **Downloads mappings once** for each unique module@version combination
81+
3. **Falls back to local mappings** if remote download fails (for local development)
82+
4. **Identifies MSAL log entries** by pattern matching for `@azure/[module]@[version]`
83+
5. **Decodes hashes** back to original messages using the appropriate mappings
84+
6. **Preserves non-MSAL lines** unchanged
85+
7. **Saves decoded output** to a new file with `-decoded` suffix
86+
87+
## Mapping File Locations
88+
89+
The script looks for mapping files in the following locations within each package:
90+
- **@azure/msal-browser**: `dist/log-strings-mapping.json`, `dist/custom-auth-path/log-strings-mapping.json`
91+
- **@azure/msal-common**: `dist-browser/log-strings-mapping.json`
92+
93+
## Cache Location
94+
95+
Downloaded mappings are cached in: `temp/log-mappings/`
96+
97+
Cache files are valid for 24 hours.

0 commit comments

Comments
 (0)