azirid-react 0.14.1 → 0.14.2
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/README.md +38 -10
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1415,7 +1415,7 @@ export function Providers({ children }: { children: React.ReactNode }) {
|
|
|
1415
1415
|
|
|
1416
1416
|
### Middleware — Route Protection & JWT Validation
|
|
1417
1417
|
|
|
1418
|
-
The middleware validates `__session` JWT cookies using JWKS (RS256) and protects routes.
|
|
1418
|
+
The middleware validates `__session` JWT cookies using JWKS (RS256) and protects routes server-side — before any HTML reaches the browser. No spinners, no flashes, no client-side redirect logic needed.
|
|
1419
1419
|
|
|
1420
1420
|
#### Next.js 16+ (`proxy.ts`)
|
|
1421
1421
|
|
|
@@ -1424,9 +1424,25 @@ The middleware validates `__session` JWT cookies using JWKS (RS256) and protects
|
|
|
1424
1424
|
import { createAziridProxy } from 'azirid-react/next/proxy'
|
|
1425
1425
|
|
|
1426
1426
|
export const proxy = createAziridProxy({
|
|
1427
|
-
|
|
1427
|
+
// Routes that REQUIRE authentication.
|
|
1428
|
+
// Uses startsWith — '/dashboard' protects '/dashboard', '/dashboard/settings', etc.
|
|
1429
|
+
protectedRoutes: ['/dashboard', '/admin', '/settings'],
|
|
1430
|
+
|
|
1431
|
+
// Where to redirect unauthenticated users (default: '/login').
|
|
1432
|
+
// The original URL is preserved as ?redirect= so you can send them back after login.
|
|
1428
1433
|
loginUrl: '/login',
|
|
1429
|
-
|
|
1434
|
+
|
|
1435
|
+
// Routes that are ALWAYS public, even if they match a protectedRoute.
|
|
1436
|
+
// Default: ['/login', '/signup', '/auth/handoff']
|
|
1437
|
+
publicRoutes: [
|
|
1438
|
+
'/login',
|
|
1439
|
+
'/register',
|
|
1440
|
+
'/forgot-password',
|
|
1441
|
+
'/reset-password',
|
|
1442
|
+
'/pricing',
|
|
1443
|
+
'/legal/terms',
|
|
1444
|
+
'/legal/privacy',
|
|
1445
|
+
],
|
|
1430
1446
|
})
|
|
1431
1447
|
|
|
1432
1448
|
export const config = {
|
|
@@ -1434,13 +1450,25 @@ export const config = {
|
|
|
1434
1450
|
}
|
|
1435
1451
|
```
|
|
1436
1452
|
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1453
|
+
#### How it works
|
|
1454
|
+
|
|
1455
|
+
1. User visits `/dashboard/settings` without a valid token
|
|
1456
|
+
2. Middleware checks: is `/dashboard/settings` protected? Yes (`startsWith('/dashboard')`)
|
|
1457
|
+
3. Middleware checks: is it public? No
|
|
1458
|
+
4. Middleware redirects to `/login?redirect=/dashboard/settings`
|
|
1459
|
+
5. After login, you can read `?redirect=` and send them back
|
|
1460
|
+
|
|
1461
|
+
Routes not listed in `protectedRoutes` are accessible to everyone (e.g. `/`, `/pricing`, `/about`).
|
|
1462
|
+
|
|
1463
|
+
#### Options
|
|
1464
|
+
|
|
1465
|
+
| Option | Type | Default | Description |
|
|
1466
|
+
| ------------------ | ---------- | -------------------------------- | ------------------------------------------------------------- |
|
|
1467
|
+
| `protectedRoutes` | `string[]` | — | Routes that require auth (matched with `startsWith`) |
|
|
1468
|
+
| `loginUrl` | `string` | `"/login"` | Redirect target for unauthenticated users |
|
|
1469
|
+
| `publicRoutes` | `string[]` | `["/login", "/signup", "/auth/handoff"]` | Always-accessible routes, even if inside a protected path |
|
|
1470
|
+
| `cookieName` | `string` | `"__session"` | Cookie carrying the access token JWT |
|
|
1471
|
+
| `jwksUrl` | `string` | auto | Override JWKS endpoint URL |
|
|
1444
1472
|
|
|
1445
1473
|
---
|
|
1446
1474
|
|
package/dist/index.cjs
CHANGED
package/dist/index.js
CHANGED
|
@@ -4851,7 +4851,7 @@ function usePasswordToggle() {
|
|
|
4851
4851
|
}
|
|
4852
4852
|
|
|
4853
4853
|
// src/index.ts
|
|
4854
|
-
var SDK_VERSION = "0.14.
|
|
4854
|
+
var SDK_VERSION = "0.14.2";
|
|
4855
4855
|
|
|
4856
4856
|
export { AUTH_BASE_PATH, AuthForm, AziridProvider, CheckoutButton, ForgotPasswordForm, HandoffCallback, InvoiceList, LoginForm, PATHS, PayButton, PayphoneCallback, PayphoneWidgetRenderer, PricingTable, ReferralCard, ReferralStats, ResetPasswordForm, SDK_VERSION, SignupForm, SubscriptionBadge, buildPaths, changePasswordSchema, cn, createAccessClient, createForgotPasswordSchema, createLoginSchema, createMutationHook, createResetPasswordConfirmSchema, createSignupSchema, en, es, forgotPasswordSchema, isAuthError, loginSchema, magicLinkRequestSchema, magicLinkVerifySchema, passkeyRegisterStartSchema, removeStyles, resetPasswordConfirmSchema, resolveMessages, signupSchema, socialLoginSchema, useAccessClient, useAzirid, useBootstrap, useBranches, useBranding, useChangePassword, useCheckout, useFormState, useInvoices, useLogin, useLogout, useMagicLink, useMessages, usePasskeys, usePasswordReset, usePasswordToggle, usePayButton, usePaymentMethods, usePaymentProviders, usePayphoneCheckout, usePayphoneConfirm, usePlans, useReferral, useReferralStats, useRefresh, useSession, useSignup, useSocialLogin, useSubmitTransferProof, useSubscription, useSwitchTenant, useTenantMembers, useTenants, useTransferPayment, useTransferProofs, useUploadTransferProof };
|
|
4857
4857
|
//# sourceMappingURL=index.js.map
|