azirid-react 0.14.5 → 0.14.6

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 CHANGED
@@ -1342,7 +1342,7 @@ The Azirid dashboard lets admins click "Sign in as user" to impersonate any end
1342
1342
  1. Admin clicks "Sign in as user" in the Azirid dashboard
1343
1343
  2. Dashboard generates a one-time handoff code (valid for 5 minutes) and redirects to your app at `/auth/handoff?code=<code>&api=<apiUrl>`
1344
1344
  3. Your app renders `<HandoffCallback>`, which exchanges the code for session tokens directly with the API
1345
- 4. Tokens are stored in `sessionStorage` on redirect to `/`, `AziridProvider` picks them up automatically
1345
+ 4. Tokens are stored in `sessionStorage` + `__session` cookie, then the component redirects to `redirectUrl` via hard navigation so `AziridProvider` re-bootstraps with the new session
1346
1346
 
1347
1347
  > **`<HandoffCallback>` is fully standalone** — it does NOT depend on `AziridProvider`. It works even when the provider wraps the entire layout and its bootstrap would redirect to `/login`. No special route groups or layout changes needed.
1348
1348
 
@@ -1356,20 +1356,19 @@ import { HandoffCallback } from 'azirid-react'
1356
1356
  export default function HandoffPage() {
1357
1357
  return (
1358
1358
  <HandoffCallback
1359
- onSuccess={() => window.location.href = '/'}
1359
+ redirectUrl="/dashboard"
1360
1360
  onError={() => window.location.href = '/login'}
1361
1361
  />
1362
1362
  )
1363
1363
  }
1364
1364
  ```
1365
1365
 
1366
- > **Important:** Use `window.location.href` (not `router.push()`) for redirects. This triggers a full page reload so `AziridProvider` re-bootstraps with the new tokens.
1367
-
1368
1366
  **Props:**
1369
1367
 
1370
1368
  | Prop | Type | Default | Description |
1371
1369
  |------|------|---------|-------------|
1372
- | `onSuccess` | `(user: unknown) => void` | | Called when the handoff succeeds; redirect the user here |
1370
+ | `redirectUrl` | `string` | `"/"` | URL to redirect after successful handoff (hard navigation) |
1371
+ | `onSuccess` | `(user: unknown) => void` | — | Called before redirect for optional side effects (analytics, etc.) |
1373
1372
  | `onError` | `(error: Error) => void` | — | Called on failure (expired/invalid code); redirect to login |
1374
1373
  | `loadingText` | `string` | `"Signing you in..."` | Text shown while the exchange is in progress |
1375
1374
  | `errorText` | `string` | `"Failed to complete sign-in. The link may have expired."` | Fallback error text |
package/dist/index.cjs CHANGED
@@ -3977,6 +3977,7 @@ var subtextStyle = {
3977
3977
  function HandoffCallback({
3978
3978
  onSuccess,
3979
3979
  onError,
3980
+ redirectUrl = "/",
3980
3981
  loadingText = "Signing you in...",
3981
3982
  errorText = "Failed to complete sign-in. The link may have expired."
3982
3983
  }) {
@@ -4003,6 +4004,7 @@ function HandoffCallback({
4003
4004
  }
4004
4005
  performHandoff(apiUrl, code).then((user) => {
4005
4006
  onSuccess?.(user);
4007
+ window.location.href = redirectUrl;
4006
4008
  }).catch((err) => {
4007
4009
  setStatus("error");
4008
4010
  const error = err instanceof Error ? err : new Error("Handoff exchange failed");
@@ -4038,7 +4040,8 @@ async function performHandoff(apiUrl, code) {
4038
4040
  }
4039
4041
  const at = json.at ?? json.accessToken;
4040
4042
  if (at) {
4041
- document.cookie = `__session=${at}; Path=/; SameSite=Lax; Max-Age=900`;
4043
+ const secure = window.location.protocol === "https:" ? "; Secure" : "";
4044
+ document.cookie = `__session=${at}; Path=/; SameSite=Lax${secure}; Max-Age=900`;
4042
4045
  }
4043
4046
  return json.user;
4044
4047
  }
@@ -4853,7 +4856,7 @@ function usePasswordToggle() {
4853
4856
  }
4854
4857
 
4855
4858
  // src/index.ts
4856
- var SDK_VERSION = "0.14.5";
4859
+ var SDK_VERSION = "0.14.6";
4857
4860
 
4858
4861
  exports.AUTH_BASE_PATH = AUTH_BASE_PATH;
4859
4862
  exports.AuthForm = AuthForm;