@sanvika/auth 1.0.13 → 1.0.15

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/dist/index.js +13 -14
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -45,15 +45,12 @@ async function ensureTokenFresh(token, thresholdSeconds = 300) {
45
45
  return token;
46
46
  }
47
47
  try {
48
- const refreshRes = await fetch(
49
- `${process.env.NEXT_PUBLIC_APP_BASE_URL || "https://accounts.sanvikaproduction.com"}/api/auth/refresh`,
50
- {
51
- method: "POST",
52
- headers: { "Content-Type": "application/json" },
53
- credentials: "include"
54
- // Send refresh token cookie
55
- }
56
- );
48
+ const refreshRes = await fetch("/api/auth/refresh", {
49
+ method: "POST",
50
+ headers: { "Content-Type": "application/json" },
51
+ credentials: "include"
52
+ // Send httpOnly refresh token cookie (same domain)
53
+ });
57
54
  if (!refreshRes.ok) {
58
55
  console.warn("[TokenRefresh] Refresh failed:", refreshRes.status);
59
56
  return token;
@@ -172,9 +169,11 @@ function SanvikaAuthProvider({
172
169
  if (token) {
173
170
  fetch(`${iamUrl}/api/auth/logout`, {
174
171
  method: "POST",
175
- headers: { "Content-Type": "application/json" },
176
- body: JSON.stringify({ logout_all: false }),
177
- credentials: "include"
172
+ headers: {
173
+ "Content-Type": "application/json",
174
+ Authorization: `Bearer ${token}`
175
+ },
176
+ body: JSON.stringify({ logout_all: false })
178
177
  }).catch(() => {
179
178
  });
180
179
  }
@@ -512,7 +511,7 @@ function SanvikaAccountButton({
512
511
  /* @__PURE__ */ jsxs(
513
512
  "a",
514
513
  {
515
- href: `https://accounts.sanvikaproduction.com/dashboard/user-profile?token=${encodeURIComponent(accessToken || "")}`,
514
+ href: `https://accounts.sanvikaproduction.com/dashboard/user-profile?token=${encodeURIComponent(accessToken || "")}&origin=${encodeURIComponent(window.location.origin)}`,
516
515
  className: "snvk-dropdownItem",
517
516
  role: "menuitem",
518
517
  onClick: () => setDropdownOpen(false),
@@ -525,7 +524,7 @@ function SanvikaAccountButton({
525
524
  /* @__PURE__ */ jsxs(
526
525
  "a",
527
526
  {
528
- href: onboardingPath && user.status === "onboarding" ? onboardingPath : `https://accounts.sanvikaproduction.com/dashboard?token=${encodeURIComponent(accessToken || "")}`,
527
+ href: onboardingPath && user.status === "onboarding" ? onboardingPath : `https://accounts.sanvikaproduction.com/dashboard?token=${encodeURIComponent(accessToken || "")}&origin=${encodeURIComponent(window.location.origin)}`,
529
528
  className: "snvk-dropdownItem",
530
529
  role: "menuitem",
531
530
  onClick: () => setDropdownOpen(false),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanvika/auth",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
4
4
  "description": "Sanvika Auth SDK — React components and hooks for Sanvika SSO integration",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",