@chemmangat/msal-next 4.0.0 → 4.0.1

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.
Files changed (2) hide show
  1. package/README.md +102 -12
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -5,22 +5,74 @@ Production-grade MSAL authentication library for Next.js App Router with minimal
5
5
  [![npm version](https://badge.fury.io/js/@chemmangat%2Fmsal-next.svg)](https://www.npmjs.com/package/@chemmangat/msal-next)
6
6
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
7
 
8
- > **📦 Current Version: 3.1.9** - Production-optimized with enhanced documentation and smaller bundle size. [See changelog](./CHANGELOG.md)
8
+ > **📦 Current Version: 4.0.1** - Zero-Config Protected Routes! Protect any page with one line of code.
9
9
 
10
- > **⚠️ Important:** If you're on v3.0.6 or v3.0.7, please update immediately - those versions have a critical popup authentication bug.
10
+ > **🚀 What's New:** Export `auth = { required: true }` from any page to protect it. No middleware, no boilerplate!
11
11
 
12
- > **💡 Having issues?** Check the [Troubleshooting Guide](./TROUBLESHOOTING.md) for common problems and solutions.
12
+ ## 🚀 What's New in v4.0.1
13
13
 
14
- ## Features
14
+ ### Zero-Config Protected Routes - THE Killer Feature
15
15
 
16
- **CLI Setup** - Get started in under 2 minutes with `npx @chemmangat/msal-next init`
17
- 🔍 **Enhanced Debugging** - Performance tracking, network logs, and log export
18
- 🔐 **Production Ready** - Comprehensive error handling, retry logic, and SSR support
19
- 🎨 **Beautiful Components** - Pre-styled Microsoft-branded UI components
20
- 🪝 **Powerful Hooks** - Easy-to-use hooks for auth, Graph API, and user data
21
- 🛡️ **Type Safe** - Full TypeScript support with generics for custom claims
22
- **Edge Compatible** - Middleware support for protecting routes at the edge
23
- 📦 **Zero Config** - Sensible defaults with full customization options
16
+ Protect any route with **one line of code**. No middleware setup, no boilerplate, just export an auth config:
17
+
18
+ ```tsx
19
+ // app/dashboard/page.tsx
20
+ export const auth = { required: true };
21
+
22
+ export default function Dashboard() {
23
+ return <div>Protected content - that's it!</div>;
24
+ }
25
+ ```
26
+
27
+ **Why This Changes Everything:**
28
+
29
+ | Before (v3.x) | After (v4.0) |
30
+ |---------------|--------------|
31
+ | 50+ lines of middleware | 1 line |
32
+ | Manual redirect logic | Automatic |
33
+ | Boilerplate in every page | Zero boilerplate |
34
+ | 30 min setup | 30 sec setup |
35
+
36
+ ### More Examples
37
+
38
+ **Role-Based Access:**
39
+ ```tsx
40
+ export const auth = {
41
+ required: true,
42
+ roles: ['admin', 'editor']
43
+ };
44
+ ```
45
+
46
+ **Custom Validation:**
47
+ ```tsx
48
+ export const auth = {
49
+ required: true,
50
+ validate: (account) => account.username.endsWith('@company.com')
51
+ };
52
+ ```
53
+
54
+ **Custom UI:**
55
+ ```tsx
56
+ export const auth = {
57
+ required: true,
58
+ loading: <Spinner />,
59
+ unauthorized: <AccessDenied />
60
+ };
61
+ ```
62
+
63
+ ---
64
+
65
+ ## Features (v4.0.1)
66
+
67
+ ✨ **Zero-Config Protection** - One line to protect any route
68
+ 🎯 **Role-Based Access** - Built-in Azure AD role checking
69
+ 🔐 **Custom Validation** - Add your own auth logic
70
+ ⚡ **Automatic Redirects** - Smart return URL handling
71
+ 🎨 **Custom UI** - Override loading/unauthorized states
72
+ 📦 **TypeScript First** - Full type safety
73
+ 🚀 **Next.js 14+** - Built for App Router
74
+
75
+ ---
24
76
 
25
77
  ## What's New in v3.0
26
78
 
@@ -626,6 +678,44 @@ Enable debug logging to troubleshoot issues:
626
678
  </MsalAuthProvider>
627
679
  ```
628
680
 
681
+ ## Migration to v4.0.1
682
+
683
+ ### From v3.x to v4.0.1
684
+
685
+ **Good news:** v4.0.0 is **100% backward compatible**! All v3.x code works without changes.
686
+
687
+ **New feature:** Zero-Config Protected Routes (optional, but recommended)
688
+
689
+ **Before (v3.x - still works):**
690
+ ```tsx
691
+ // middleware.ts
692
+ export async function middleware(request) {
693
+ const session = await getServerSession();
694
+ if (!session) return redirect('/login');
695
+ }
696
+
697
+ // app/dashboard/page.tsx
698
+ export default async function Dashboard() {
699
+ const session = await getServerSession();
700
+ if (!session) redirect('/login');
701
+ return <div>Protected</div>;
702
+ }
703
+ ```
704
+
705
+ **After (v4.0 - recommended):**
706
+ ```tsx
707
+ // app/dashboard/page.tsx
708
+ export const auth = { required: true };
709
+
710
+ export default function Dashboard() {
711
+ return <div>Protected</div>;
712
+ }
713
+ ```
714
+
715
+ **That's it!** No breaking changes, just a better way to protect routes.
716
+
717
+ ---
718
+
629
719
  ## Migration Guide
630
720
 
631
721
  ### From v2.x to v3.0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chemmangat/msal-next",
3
- "version": "4.0.0",
3
+ "version": "4.0.1",
4
4
  "description": "Production-grade MSAL authentication package for Next.js App Router with minimal boilerplate",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",