@chemmangat/msal-next 4.2.1 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,91 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [5.0.0] - 2026-03-16
6
+
7
+ ### ⚠️ Breaking Changes
8
+
9
+ - **Node.js 18+ required** — The CLI and codemod tools require Node.js 18 or higher.
10
+ - **CLI package renamed** — `@chemmangat/msal-next-cli` is now the canonical CLI package, invokable via `npx @chemmangat/msal-next init`.
11
+ - **Codemod is a breaking addition** — Running `npx @chemmangat/msal-next migrate` will rewrite popup API calls in your project. Review changes with `git diff` before committing.
12
+
13
+ ### ✨ New Features
14
+
15
+ #### 1. Interactive CLI — `npx @chemmangat/msal-next init`
16
+ The `init` command now interactively collects all required configuration:
17
+ - Azure AD **Client ID** and **Tenant ID**
18
+ - **Authority type** (`common`, `organizations`, `consumers`, `tenant`)
19
+ - **Cache location** (`sessionStorage`, `localStorage`, `memoryStorage`)
20
+
21
+ After collecting answers it automatically:
22
+ - Creates `.env.local` with all environment variables
23
+ - Updates (or creates) `app/layout.tsx` with `MSALProvider` wired up
24
+ - Creates a starter `app/auth/page.tsx` using `useMsalAuth` and `MicrosoftSignInButton`
25
+
26
+ ```bash
27
+ npx @chemmangat/msal-next init
28
+ ```
29
+
30
+ #### 2. UI Component Slots — `renderAccount` prop
31
+ Both `AccountSwitcher` and `AccountList` now accept a `renderAccount` render prop that lets consumers fully customize how each account row is displayed.
32
+
33
+ ```tsx
34
+ <AccountSwitcher
35
+ renderAccount={(account, isActive) => (
36
+ <div style={{ fontWeight: isActive ? 'bold' : 'normal' }}>
37
+ {account.name} — {account.username}
38
+ </div>
39
+ )}
40
+ />
41
+
42
+ <AccountList
43
+ renderAccount={(account, isActive) => (
44
+ <span>{account.name} {isActive ? '✓' : ''}</span>
45
+ )}
46
+ />
47
+ ```
48
+
49
+ #### 3. Comprehensive Test Coverage (80%+)
50
+ Full Vitest + `@testing-library/react` test suite covering:
51
+ - All hooks: `useMsalAuth`, `useUserProfile`, `useRoles`, `useTokenRefresh`, `useMultiAccount`, `useGraphApi`
52
+ - All components: `MicrosoftSignInButton`, `SignOutButton`, `UserAvatar`, `AuthStatus`, `AuthGuard`, `AccountSwitcher`, `AccountList`
53
+
54
+ Run tests:
55
+ ```bash
56
+ npm test # single run
57
+ npm run test:coverage # with coverage report
58
+ ```
59
+
60
+ #### 4. Codemod — `npx @chemmangat/msal-next migrate`
61
+ Scans your project and replaces deprecated popup API calls with their redirect equivalents:
62
+
63
+ | Before | After |
64
+ |--------|-------|
65
+ | `loginPopup()` | `loginRedirect()` |
66
+ | `logoutPopup()` | `logoutRedirect()` |
67
+ | `acquireTokenPopup()` | `acquireTokenRedirect()` |
68
+ | `useRedirect={false}` | *(removed)* |
69
+
70
+ Prints a summary of all files modified and occurrences replaced.
71
+
72
+ ```bash
73
+ npx @chemmangat/msal-next migrate
74
+ ```
75
+
76
+ ### 🔄 Migration from v4.x
77
+
78
+ ```bash
79
+ npm install @chemmangat/msal-next@5.0.0
80
+ ```
81
+
82
+ If you have any popup API usage, run the codemod:
83
+ ```bash
84
+ npx @chemmangat/msal-next migrate
85
+ git diff # review changes
86
+ ```
87
+
88
+ ---
89
+
5
90
  ## [4.2.0] - 2026-03-08
6
91
 
7
92
  ### 🎉 Major Feature Release - Multi-Account Management