@sanvika/auth 1.0.16 → 1.0.18

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 +6 -8
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -19,7 +19,6 @@ var STORAGE_KEYS = {
19
19
  RETURN_PATH: "sanvika_return_path"
20
20
  // Page to redirect back after login
21
21
  };
22
- var DEFAULT_IAM_URL = "https://accounts.sanvikaproduction.com";
23
22
  var DEFAULT_AVATAR_SVG = `data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Ccircle cx='20' cy='20' r='20' fill='%23e5e7eb'/%3E%3Ccircle cx='20' cy='15' r='7' fill='%23adb5bd'/%3E%3Cellipse cx='20' cy='35' rx='12' ry='8' fill='%23adb5bd'/%3E%3C/svg%3E`;
24
23
 
25
24
  // tokenRefreshUtils.js
@@ -89,12 +88,12 @@ function scheduleTokenRefresh(token, onRefresh) {
89
88
 
90
89
  // SanvikaAuthProvider.jsx
91
90
  import { jsx } from "react/jsx-runtime";
91
+ var SA_URL = "https://accounts.sanvikaproduction.com";
92
92
  var SanvikaAuthContext = createContext(null);
93
93
  function SanvikaAuthProvider({
94
94
  children,
95
95
  clientId,
96
96
  redirectUri,
97
- iamUrl = DEFAULT_IAM_URL,
98
97
  dashboardPath = "/dashboard"
99
98
  }) {
100
99
  const [user, setUser] = useState(null);
@@ -167,7 +166,7 @@ function SanvikaAuthProvider({
167
166
  const logout = useCallback(async () => {
168
167
  const token = localStorage.getItem(STORAGE_KEYS.ACCESS_TOKEN);
169
168
  if (token) {
170
- fetch(`${iamUrl}/api/auth/logout`, {
169
+ fetch(`${SA_URL}/api/auth/logout`, {
171
170
  method: "POST",
172
171
  headers: {
173
172
  "Content-Type": "application/json",
@@ -181,7 +180,7 @@ function SanvikaAuthProvider({
181
180
  localStorage.removeItem(STORAGE_KEYS.USER);
182
181
  setUser(null);
183
182
  setToken(null);
184
- }, [iamUrl]);
183
+ }, []);
185
184
  const updateUser = useCallback((partial) => {
186
185
  setUser((prev) => {
187
186
  if (!prev) return prev;
@@ -197,7 +196,7 @@ function SanvikaAuthProvider({
197
196
  }
198
197
  const state = Math.random().toString(36).slice(2);
199
198
  localStorage.setItem(STORAGE_KEYS.STATE, state);
200
- const url = new URL(`${iamUrl}/authorize`);
199
+ const url = new URL(`${SA_URL}/authorize`);
201
200
  url.searchParams.set("client_id", clientId);
202
201
  url.searchParams.set("redirect_uri", redirectUri);
203
202
  url.searchParams.set("response_type", "code");
@@ -208,7 +207,7 @@ function SanvikaAuthProvider({
208
207
  }
209
208
  window.location.href = url.toString();
210
209
  },
211
- [iamUrl, clientId, redirectUri]
210
+ [clientId, redirectUri]
212
211
  );
213
212
  return /* @__PURE__ */ jsx(
214
213
  SanvikaAuthContext.Provider,
@@ -224,7 +223,6 @@ function SanvikaAuthProvider({
224
223
  redirectToLogin,
225
224
  clientId,
226
225
  redirectUri,
227
- iamUrl,
228
226
  dashboardPath
229
227
  },
230
228
  children
@@ -570,12 +568,12 @@ function SanvikaAccountButton({
570
568
  }
571
569
  export {
572
570
  DEFAULT_AVATAR_SVG,
573
- DEFAULT_IAM_URL,
574
571
  STORAGE_KEYS,
575
572
  SanvikaAccountButton,
576
573
  SanvikaAuthContext,
577
574
  SanvikaAuthProvider,
578
575
  decodeToken,
579
576
  ensureTokenFresh,
577
+ scheduleTokenRefresh,
580
578
  useSanvikaAuth
581
579
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanvika/auth",
3
- "version": "1.0.16",
3
+ "version": "1.0.18",
4
4
  "description": "Sanvika Auth SDK — React components and hooks for Sanvika SSO integration",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",