azirid-react 0.14.0 → 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 +40 -29
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -10
- package/dist/index.d.ts +1 -10
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -33,10 +33,7 @@ import { AziridProvider } from 'azirid-react'
|
|
|
33
33
|
|
|
34
34
|
export default function RootLayout({ children }: { children: React.ReactNode }) {
|
|
35
35
|
return (
|
|
36
|
-
<AziridProvider
|
|
37
|
-
publishableKey={process.env.NEXT_PUBLIC_AZIRID_PK!}
|
|
38
|
-
apiUrl={process.env.NEXT_PUBLIC_AZIRID_API_URL}
|
|
39
|
-
>
|
|
36
|
+
<AziridProvider publishableKey={process.env.NEXT_PUBLIC_AZIRID_PK!}>
|
|
40
37
|
{children}
|
|
41
38
|
</AziridProvider>
|
|
42
39
|
)
|
|
@@ -76,10 +73,7 @@ export default function LoginPage() {
|
|
|
76
73
|
|
|
77
74
|
```env
|
|
78
75
|
# .env
|
|
79
|
-
NEXT_PUBLIC_AZIRID_API_URL=https://api.azirid.com
|
|
80
76
|
NEXT_PUBLIC_AZIRID_PK=pk_live_...
|
|
81
|
-
# Server-side only (used by middleware for JWKS validation)
|
|
82
|
-
AZIRID_API_URL=https://api.azirid.com
|
|
83
77
|
```
|
|
84
78
|
|
|
85
79
|
---
|
|
@@ -93,10 +87,7 @@ AZIRID_API_URL=https://api.azirid.com
|
|
|
93
87
|
import { AziridProvider } from 'azirid-react'
|
|
94
88
|
|
|
95
89
|
createRoot(document.getElementById('root')!).render(
|
|
96
|
-
<AziridProvider
|
|
97
|
-
apiUrl={import.meta.env.VITE_AZIRID_API_URL || 'https://api.azirid.com'}
|
|
98
|
-
publishableKey={import.meta.env.VITE_AZIRID_PK}
|
|
99
|
-
>
|
|
90
|
+
<AziridProvider publishableKey={import.meta.env.VITE_AZIRID_PK}>
|
|
100
91
|
<App />
|
|
101
92
|
</AziridProvider>,
|
|
102
93
|
)
|
|
@@ -105,7 +96,6 @@ createRoot(document.getElementById('root')!).render(
|
|
|
105
96
|
### 2. Configure your environment
|
|
106
97
|
|
|
107
98
|
```env
|
|
108
|
-
VITE_AZIRID_API_URL=https://api.azirid.com
|
|
109
99
|
VITE_AZIRID_PK=pk_live_...
|
|
110
100
|
```
|
|
111
101
|
|
|
@@ -1306,7 +1296,6 @@ function createAccessClient(
|
|
|
1306
1296
|
| Prop | Type | Default | Description |
|
|
1307
1297
|
| ------------------ | ------------------------- | ------- | -------------------------------------------------------------------------------- |
|
|
1308
1298
|
| `children` | `ReactNode` | — | **Required.** Your app tree |
|
|
1309
|
-
| `apiUrl` | `string` | `https://api.azirid.com` | Azirid API URL. Set for local dev or custom deployments |
|
|
1310
1299
|
| `publishableKey` | `string` | — | Publishable key (e.g. `pk_live_...`) |
|
|
1311
1300
|
| `tenantId` | `string` | — | Tenant ID for multi-tenant apps |
|
|
1312
1301
|
| `fetchOptions` | `Record<string, string>` | — | Extra headers to send with every request |
|
|
@@ -1426,7 +1415,7 @@ export function Providers({ children }: { children: React.ReactNode }) {
|
|
|
1426
1415
|
|
|
1427
1416
|
### Middleware — Route Protection & JWT Validation
|
|
1428
1417
|
|
|
1429
|
-
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.
|
|
1430
1419
|
|
|
1431
1420
|
#### Next.js 16+ (`proxy.ts`)
|
|
1432
1421
|
|
|
@@ -1435,9 +1424,25 @@ The middleware validates `__session` JWT cookies using JWKS (RS256) and protects
|
|
|
1435
1424
|
import { createAziridProxy } from 'azirid-react/next/proxy'
|
|
1436
1425
|
|
|
1437
1426
|
export const proxy = createAziridProxy({
|
|
1438
|
-
|
|
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.
|
|
1439
1433
|
loginUrl: '/login',
|
|
1440
|
-
|
|
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
|
+
],
|
|
1441
1446
|
})
|
|
1442
1447
|
|
|
1443
1448
|
export const config = {
|
|
@@ -1445,19 +1450,25 @@ export const config = {
|
|
|
1445
1450
|
}
|
|
1446
1451
|
```
|
|
1447
1452
|
|
|
1448
|
-
|
|
1449
|
-
| ------------------ | ---------- | ------------- | ------------------------------------------------ |
|
|
1450
|
-
| `cookieName` | `string` | `"__session"` | Cookie carrying the access token JWT |
|
|
1451
|
-
| `protectedRoutes` | `string[]` | — | Routes that require authentication |
|
|
1452
|
-
| `loginUrl` | `string` | `"/login"` | Redirect target for unauthenticated users |
|
|
1453
|
-
| `publicRoutes` | `string[]` | login/signup | Always-accessible routes |
|
|
1454
|
-
| `jwksUrl` | `string` | auto | Override JWKS endpoint URL |
|
|
1453
|
+
#### How it works
|
|
1455
1454
|
|
|
1456
|
-
|
|
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
|
|
1457
1460
|
|
|
1458
|
-
|
|
1459
|
-
|
|
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 |
|
|
1461
1472
|
|
|
1462
1473
|
---
|
|
1463
1474
|
|
|
@@ -1489,7 +1500,7 @@ export async function getProfile() {
|
|
|
1489
1500
|
const token = await getSessionToken()
|
|
1490
1501
|
if (!token) throw new Error('Not authenticated')
|
|
1491
1502
|
|
|
1492
|
-
const res = await fetch(
|
|
1503
|
+
const res = await fetch('https://api.azirid.com/v1/users/auth/me', {
|
|
1493
1504
|
headers: { Authorization: `Bearer ${token}` },
|
|
1494
1505
|
})
|
|
1495
1506
|
return res.json()
|
|
@@ -1507,7 +1518,7 @@ export default async function DashboardPage() {
|
|
|
1507
1518
|
const token = await getSessionToken()
|
|
1508
1519
|
if (!token) redirect('/login')
|
|
1509
1520
|
|
|
1510
|
-
const res = await fetch(
|
|
1521
|
+
const res = await fetch('https://api.azirid.com/v1/users/auth/me', {
|
|
1511
1522
|
headers: { Authorization: `Bearer ${token}` },
|
|
1512
1523
|
})
|
|
1513
1524
|
const user = await res.json()
|
package/dist/index.cjs
CHANGED
package/dist/index.d.cts
CHANGED
|
@@ -202,16 +202,7 @@ interface RegisterPasskeyData {
|
|
|
202
202
|
}
|
|
203
203
|
interface AziridProviderProps {
|
|
204
204
|
children: ReactNode;
|
|
205
|
-
/**
|
|
206
|
-
* Azirid API URL. Defaults to `https://api.azirid.com`.
|
|
207
|
-
*
|
|
208
|
-
* Set this to your API URL for local development or custom deployments.
|
|
209
|
-
*
|
|
210
|
-
* @example
|
|
211
|
-
* ```tsx
|
|
212
|
-
* <AziridProvider apiUrl="http://localhost:3000" publishableKey="pk_dev_...">
|
|
213
|
-
* ```
|
|
214
|
-
*/
|
|
205
|
+
/** @internal Override API URL. Only for Azirid monorepo development. */
|
|
215
206
|
apiUrl?: string;
|
|
216
207
|
/** Extra headers to send with every request */
|
|
217
208
|
fetchOptions?: Record<string, string>;
|
package/dist/index.d.ts
CHANGED
|
@@ -202,16 +202,7 @@ interface RegisterPasskeyData {
|
|
|
202
202
|
}
|
|
203
203
|
interface AziridProviderProps {
|
|
204
204
|
children: ReactNode;
|
|
205
|
-
/**
|
|
206
|
-
* Azirid API URL. Defaults to `https://api.azirid.com`.
|
|
207
|
-
*
|
|
208
|
-
* Set this to your API URL for local development or custom deployments.
|
|
209
|
-
*
|
|
210
|
-
* @example
|
|
211
|
-
* ```tsx
|
|
212
|
-
* <AziridProvider apiUrl="http://localhost:3000" publishableKey="pk_dev_...">
|
|
213
|
-
* ```
|
|
214
|
-
*/
|
|
205
|
+
/** @internal Override API URL. Only for Azirid monorepo development. */
|
|
215
206
|
apiUrl?: string;
|
|
216
207
|
/** Extra headers to send with every request */
|
|
217
208
|
fetchOptions?: Record<string, string>;
|
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
|