@sanvika/auth 1.0.20 → 1.0.22
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/dist/index.js +145 -248
- package/package.json +1 -2
package/dist/index.js
CHANGED
|
@@ -1,105 +1,23 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
// SanvikaAuthProvider.jsx
|
|
4
|
-
import {
|
|
5
|
-
createContext,
|
|
6
|
-
useContext,
|
|
7
|
-
useEffect,
|
|
8
|
-
useState,
|
|
9
|
-
useCallback,
|
|
10
|
-
useRef
|
|
11
|
-
} from "react";
|
|
4
|
+
import { createContext, useContext, useEffect, useState } from "react";
|
|
12
5
|
|
|
13
6
|
// constants.js
|
|
14
7
|
var STORAGE_KEYS = {
|
|
15
8
|
ACCESS_TOKEN: "sanvika_access_token",
|
|
16
|
-
USER: "sanvika_user"
|
|
17
|
-
STATE: "sanvika_oauth_state",
|
|
18
|
-
// CSRF state for OAuth flow
|
|
19
|
-
RETURN_PATH: "sanvika_return_path"
|
|
20
|
-
// Page to redirect back after login
|
|
9
|
+
USER: "sanvika_user"
|
|
21
10
|
};
|
|
22
11
|
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`;
|
|
23
12
|
|
|
24
|
-
// tokenRefreshUtils.js
|
|
25
|
-
function decodeToken(token) {
|
|
26
|
-
try {
|
|
27
|
-
const base64Url = token.split(".")[1];
|
|
28
|
-
const base64 = base64Url.replace(/-/g, "+").replace(/_/g, "/");
|
|
29
|
-
const jsonPayload = decodeURIComponent(
|
|
30
|
-
atob(base64).split("").map((c) => "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2)).join("")
|
|
31
|
-
);
|
|
32
|
-
return JSON.parse(jsonPayload);
|
|
33
|
-
} catch {
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
async function ensureTokenFresh(token, thresholdSeconds = 300) {
|
|
38
|
-
if (!token) return null;
|
|
39
|
-
const decoded = decodeToken(token);
|
|
40
|
-
if (!decoded || !decoded.exp) return token;
|
|
41
|
-
const nowSeconds = Math.floor(Date.now() / 1e3);
|
|
42
|
-
const secondsUntilExpiry = decoded.exp - nowSeconds;
|
|
43
|
-
if (secondsUntilExpiry > thresholdSeconds) {
|
|
44
|
-
return token;
|
|
45
|
-
}
|
|
46
|
-
try {
|
|
47
|
-
const refreshRes = await fetch("/api/auth/refresh", {
|
|
48
|
-
method: "POST",
|
|
49
|
-
headers: { "Content-Type": "application/json" },
|
|
50
|
-
credentials: "include"
|
|
51
|
-
// Send httpOnly refresh token cookie (same domain)
|
|
52
|
-
});
|
|
53
|
-
if (!refreshRes.ok) {
|
|
54
|
-
console.warn("[TokenRefresh] Refresh failed:", refreshRes.status);
|
|
55
|
-
return token;
|
|
56
|
-
}
|
|
57
|
-
const data = await refreshRes.json();
|
|
58
|
-
if (data.success && data.accessToken) {
|
|
59
|
-
localStorage.setItem(STORAGE_KEYS.ACCESS_TOKEN, data.accessToken);
|
|
60
|
-
return data.accessToken;
|
|
61
|
-
}
|
|
62
|
-
} catch (err) {
|
|
63
|
-
console.warn("[TokenRefresh] Error refreshing token:", err.message);
|
|
64
|
-
}
|
|
65
|
-
return token;
|
|
66
|
-
}
|
|
67
|
-
function scheduleTokenRefresh(token, onRefresh) {
|
|
68
|
-
if (!token) return () => {
|
|
69
|
-
};
|
|
70
|
-
const decoded = decodeToken(token);
|
|
71
|
-
if (!decoded || !decoded.exp) return () => {
|
|
72
|
-
};
|
|
73
|
-
const nowSeconds = Math.floor(Date.now() / 1e3);
|
|
74
|
-
const secondsUntilExpiry = decoded.exp - nowSeconds;
|
|
75
|
-
const refreshAt = Math.max(60, Math.floor(secondsUntilExpiry * 0.75));
|
|
76
|
-
const timeoutId = setTimeout(async () => {
|
|
77
|
-
try {
|
|
78
|
-
const freshToken = await ensureTokenFresh(token, 0);
|
|
79
|
-
if (freshToken !== token && onRefresh) {
|
|
80
|
-
onRefresh(freshToken);
|
|
81
|
-
}
|
|
82
|
-
} catch (err) {
|
|
83
|
-
console.warn("[TokenRefresh] Auto-refresh failed:", err.message);
|
|
84
|
-
}
|
|
85
|
-
}, refreshAt * 1e3);
|
|
86
|
-
return () => clearTimeout(timeoutId);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
13
|
// SanvikaAuthProvider.jsx
|
|
90
14
|
import { jsx } from "react/jsx-runtime";
|
|
91
15
|
var SA_URL = "https://accounts.sanvikaproduction.com";
|
|
92
16
|
var SanvikaAuthContext = createContext(null);
|
|
93
|
-
function SanvikaAuthProvider({
|
|
94
|
-
children,
|
|
95
|
-
clientId,
|
|
96
|
-
redirectUri,
|
|
97
|
-
dashboardPath = "/dashboard"
|
|
98
|
-
}) {
|
|
17
|
+
function SanvikaAuthProvider({ children }) {
|
|
99
18
|
const [user, setUser] = useState(null);
|
|
100
19
|
const [accessToken, setToken] = useState(null);
|
|
101
20
|
const [loading, setLoading] = useState(true);
|
|
102
|
-
const refreshCleanupRef = useRef(null);
|
|
103
21
|
useEffect(() => {
|
|
104
22
|
try {
|
|
105
23
|
const storedToken = localStorage.getItem(STORAGE_KEYS.ACCESS_TOKEN);
|
|
@@ -108,136 +26,69 @@ function SanvikaAuthProvider({
|
|
|
108
26
|
setToken(storedToken);
|
|
109
27
|
setUser(JSON.parse(storedUser));
|
|
110
28
|
}
|
|
111
|
-
} catch {
|
|
112
|
-
|
|
113
|
-
localStorage.removeItem(STORAGE_KEYS.USER);
|
|
29
|
+
} catch (e) {
|
|
30
|
+
console.error("[SanvikaAuth] Failed to load from localStorage:", e);
|
|
114
31
|
} finally {
|
|
115
32
|
setLoading(false);
|
|
116
33
|
}
|
|
117
34
|
}, []);
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
} catch {
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
window.addEventListener("storage", onStorage);
|
|
134
|
-
return () => window.removeEventListener("storage", onStorage);
|
|
135
|
-
}, []);
|
|
136
|
-
useEffect(() => {
|
|
137
|
-
if (!accessToken) {
|
|
138
|
-
if (refreshCleanupRef.current) {
|
|
139
|
-
refreshCleanupRef.current();
|
|
140
|
-
refreshCleanupRef.current = null;
|
|
141
|
-
}
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
const cleanup = scheduleTokenRefresh(accessToken, (freshToken) => {
|
|
145
|
-
localStorage.setItem(STORAGE_KEYS.ACCESS_TOKEN, freshToken);
|
|
146
|
-
setToken(freshToken);
|
|
147
|
-
window.dispatchEvent(
|
|
148
|
-
new StorageEvent("storage", {
|
|
149
|
-
key: STORAGE_KEYS.ACCESS_TOKEN,
|
|
150
|
-
newValue: freshToken,
|
|
151
|
-
oldValue: accessToken
|
|
152
|
-
})
|
|
153
|
-
);
|
|
35
|
+
const login = async ({ mobile, password, deviceId, deviceName }) => {
|
|
36
|
+
const response = await fetch(`${SA_URL}/api/auth/login`, {
|
|
37
|
+
method: "POST",
|
|
38
|
+
headers: { "Content-Type": "application/json" },
|
|
39
|
+
credentials: "include",
|
|
40
|
+
body: JSON.stringify({
|
|
41
|
+
mobile,
|
|
42
|
+
password,
|
|
43
|
+
deviceId: deviceId || crypto.randomUUID(),
|
|
44
|
+
deviceName: deviceName || "Browser"
|
|
45
|
+
})
|
|
154
46
|
});
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
const logout = useCallback(async () => {
|
|
167
|
-
const token = localStorage.getItem(STORAGE_KEYS.ACCESS_TOKEN);
|
|
168
|
-
if (token) {
|
|
169
|
-
fetch(`${SA_URL}/api/auth/logout`, {
|
|
47
|
+
const data = await response.json();
|
|
48
|
+
if (!data.success) throw new Error(data.error);
|
|
49
|
+
localStorage.setItem(STORAGE_KEYS.ACCESS_TOKEN, data.accessToken);
|
|
50
|
+
localStorage.setItem(STORAGE_KEYS.USER, JSON.stringify(data.user));
|
|
51
|
+
setToken(data.accessToken);
|
|
52
|
+
setUser(data.user);
|
|
53
|
+
return data;
|
|
54
|
+
};
|
|
55
|
+
const logout = async (logoutAll = false) => {
|
|
56
|
+
try {
|
|
57
|
+
await fetch(`${SA_URL}/api/auth/logout`, {
|
|
170
58
|
method: "POST",
|
|
171
59
|
headers: {
|
|
172
60
|
"Content-Type": "application/json",
|
|
173
|
-
Authorization: `Bearer ${
|
|
61
|
+
Authorization: `Bearer ${accessToken}`
|
|
174
62
|
},
|
|
175
|
-
|
|
176
|
-
|
|
63
|
+
credentials: "include",
|
|
64
|
+
body: JSON.stringify({ logout_all: logoutAll })
|
|
177
65
|
});
|
|
66
|
+
} catch (e) {
|
|
67
|
+
console.error("[SanvikaAuth] Logout API error:", e);
|
|
68
|
+
} finally {
|
|
69
|
+
localStorage.removeItem(STORAGE_KEYS.ACCESS_TOKEN);
|
|
70
|
+
localStorage.removeItem(STORAGE_KEYS.USER);
|
|
71
|
+
setToken(null);
|
|
72
|
+
setUser(null);
|
|
178
73
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
return merged;
|
|
190
|
-
});
|
|
191
|
-
}, []);
|
|
192
|
-
const redirectToLogin = useCallback(
|
|
193
|
-
(returnPath) => {
|
|
194
|
-
if (returnPath) {
|
|
195
|
-
localStorage.setItem(STORAGE_KEYS.RETURN_PATH, returnPath);
|
|
196
|
-
}
|
|
197
|
-
const state = Math.random().toString(36).slice(2);
|
|
198
|
-
localStorage.setItem(STORAGE_KEYS.STATE, state);
|
|
199
|
-
const url = new URL(`${SA_URL}/authorize`);
|
|
200
|
-
url.searchParams.set("client_id", clientId);
|
|
201
|
-
url.searchParams.set("redirect_uri", redirectUri);
|
|
202
|
-
url.searchParams.set("response_type", "code");
|
|
203
|
-
url.searchParams.set("state", state);
|
|
204
|
-
const appTheme = localStorage.getItem("theme");
|
|
205
|
-
if (appTheme === "light" || appTheme === "dark") {
|
|
206
|
-
url.searchParams.set("theme", appTheme);
|
|
207
|
-
}
|
|
208
|
-
window.location.href = url.toString();
|
|
209
|
-
},
|
|
210
|
-
[clientId, redirectUri]
|
|
211
|
-
);
|
|
212
|
-
return /* @__PURE__ */ jsx(
|
|
213
|
-
SanvikaAuthContext.Provider,
|
|
214
|
-
{
|
|
215
|
-
value: {
|
|
216
|
-
user,
|
|
217
|
-
accessToken,
|
|
218
|
-
loading,
|
|
219
|
-
isLoggedIn: !!user,
|
|
220
|
-
login,
|
|
221
|
-
logout,
|
|
222
|
-
updateUser,
|
|
223
|
-
redirectToLogin,
|
|
224
|
-
clientId,
|
|
225
|
-
redirectUri,
|
|
226
|
-
dashboardPath
|
|
227
|
-
},
|
|
228
|
-
children
|
|
229
|
-
}
|
|
230
|
-
);
|
|
74
|
+
};
|
|
75
|
+
const value = {
|
|
76
|
+
user,
|
|
77
|
+
accessToken,
|
|
78
|
+
loading,
|
|
79
|
+
isAuthenticated: !!user,
|
|
80
|
+
login,
|
|
81
|
+
logout
|
|
82
|
+
};
|
|
83
|
+
return /* @__PURE__ */ jsx(SanvikaAuthContext.Provider, { value, children });
|
|
231
84
|
}
|
|
232
85
|
function useSanvikaAuth() {
|
|
233
86
|
const ctx = useContext(SanvikaAuthContext);
|
|
234
|
-
if (!ctx)
|
|
235
|
-
throw new Error("useSanvikaAuth must be used inside <SanvikaAuthProvider>");
|
|
236
87
|
return ctx;
|
|
237
88
|
}
|
|
238
89
|
|
|
239
90
|
// SanvikaAccountButton.jsx
|
|
240
|
-
import { useEffect as useEffect2, useRef
|
|
91
|
+
import { useEffect as useEffect2, useRef, useState as useState2, Component } from "react";
|
|
241
92
|
|
|
242
93
|
// #style-inject:#style-inject
|
|
243
94
|
function styleInject(css, { insertAt } = {}) {
|
|
@@ -266,6 +117,22 @@ styleInject("@keyframes snvk-shimmer {\n 0% {\n background-position: 200% 0;
|
|
|
266
117
|
|
|
267
118
|
// SanvikaAccountButton.jsx
|
|
268
119
|
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
120
|
+
var SanvikaAccountButtonErrorBoundary = class extends Component {
|
|
121
|
+
constructor(props) {
|
|
122
|
+
super(props);
|
|
123
|
+
this.state = { hasError: false };
|
|
124
|
+
}
|
|
125
|
+
static getDerivedStateFromError(error) {
|
|
126
|
+
return { hasError: true };
|
|
127
|
+
}
|
|
128
|
+
static displayName = "SanvikaAccountButtonErrorBoundary";
|
|
129
|
+
render() {
|
|
130
|
+
if (this.state.hasError) {
|
|
131
|
+
return /* @__PURE__ */ jsx2("div", { className: "snvk-skeleton", "aria-hidden": "true" });
|
|
132
|
+
}
|
|
133
|
+
return this.props.children;
|
|
134
|
+
}
|
|
135
|
+
};
|
|
269
136
|
function UserIcon({ size = 18 }) {
|
|
270
137
|
return /* @__PURE__ */ jsxs(
|
|
271
138
|
"svg",
|
|
@@ -324,48 +191,21 @@ function DashboardIcon() {
|
|
|
324
191
|
}
|
|
325
192
|
);
|
|
326
193
|
}
|
|
327
|
-
function
|
|
328
|
-
text
|
|
329
|
-
hideTextOnMobile
|
|
194
|
+
function SanvikaAccountButtonContent({
|
|
195
|
+
text,
|
|
196
|
+
hideTextOnMobile,
|
|
330
197
|
onLoginClick,
|
|
331
198
|
onProfileClick,
|
|
332
|
-
onboardingPath
|
|
333
|
-
className
|
|
199
|
+
onboardingPath,
|
|
200
|
+
className
|
|
334
201
|
}) {
|
|
335
|
-
var _a;
|
|
336
|
-
const
|
|
337
|
-
|
|
338
|
-
loading,
|
|
339
|
-
isLoggedIn,
|
|
340
|
-
redirectToLogin,
|
|
341
|
-
dashboardPath,
|
|
342
|
-
updateUser
|
|
343
|
-
} = useSanvikaAuth();
|
|
202
|
+
var _a, _b;
|
|
203
|
+
const auth = useSanvikaAuth();
|
|
204
|
+
console.log("[SanvikaAccountButton] auth context:", auth);
|
|
344
205
|
const [dropdownOpen, setDropdownOpen] = useState2(false);
|
|
345
206
|
const [imgError, setImgError] = useState2(false);
|
|
346
|
-
const [prevImage, setPrevImage] = useState2(user == null ? void 0 :
|
|
347
|
-
const wrapperRef =
|
|
348
|
-
if ((user == null ? void 0 : user.image) !== prevImage) {
|
|
349
|
-
setPrevImage(user == null ? void 0 : user.image);
|
|
350
|
-
setImgError(false);
|
|
351
|
-
}
|
|
352
|
-
useEffect2(() => {
|
|
353
|
-
if (!user) return;
|
|
354
|
-
let disposed = false;
|
|
355
|
-
const handleProfileUpdated = async () => {
|
|
356
|
-
if (disposed) return;
|
|
357
|
-
try {
|
|
358
|
-
const stored = localStorage.getItem("sanvika_user");
|
|
359
|
-
if (stored) updateUser(JSON.parse(stored));
|
|
360
|
-
} catch {
|
|
361
|
-
}
|
|
362
|
-
};
|
|
363
|
-
window.addEventListener("profileUpdated", handleProfileUpdated);
|
|
364
|
-
return () => {
|
|
365
|
-
disposed = true;
|
|
366
|
-
window.removeEventListener("profileUpdated", handleProfileUpdated);
|
|
367
|
-
};
|
|
368
|
-
}, [user, updateUser]);
|
|
207
|
+
const [prevImage, setPrevImage] = useState2((_a = auth == null ? void 0 : auth.user) == null ? void 0 : _a.image);
|
|
208
|
+
const wrapperRef = useRef(null);
|
|
369
209
|
useEffect2(() => {
|
|
370
210
|
if (!dropdownOpen) return;
|
|
371
211
|
function handleOutside(e) {
|
|
@@ -376,10 +216,38 @@ function SanvikaAccountButton({
|
|
|
376
216
|
document.addEventListener("mousedown", handleOutside);
|
|
377
217
|
return () => document.removeEventListener("mousedown", handleOutside);
|
|
378
218
|
}, [dropdownOpen]);
|
|
379
|
-
if (
|
|
380
|
-
return /* @__PURE__ */
|
|
219
|
+
if (!auth) {
|
|
220
|
+
return /* @__PURE__ */ jsxs(
|
|
221
|
+
"button",
|
|
222
|
+
{
|
|
223
|
+
className: `snvk-guestBtn ${className}`,
|
|
224
|
+
onClick: () => {
|
|
225
|
+
if (onLoginClick) {
|
|
226
|
+
onLoginClick();
|
|
227
|
+
} else {
|
|
228
|
+
window.location.href = "https://accounts.sanvikaproduction.com";
|
|
229
|
+
}
|
|
230
|
+
},
|
|
231
|
+
"aria-label": "Login or Sign Up",
|
|
232
|
+
children: [
|
|
233
|
+
/* @__PURE__ */ jsx2("span", { className: "snvk-iconWrap", children: /* @__PURE__ */ jsx2(UserIcon, { size: 18 }) }),
|
|
234
|
+
/* @__PURE__ */ jsx2(
|
|
235
|
+
"span",
|
|
236
|
+
{
|
|
237
|
+
className: hideTextOnMobile ? "snvk-hideTextOnMobile" : "snvk-textWrap",
|
|
238
|
+
children: text
|
|
239
|
+
}
|
|
240
|
+
)
|
|
241
|
+
]
|
|
242
|
+
}
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
const { user, loading, isAuthenticated, logout } = auth;
|
|
246
|
+
if ((user == null ? void 0 : user.image) !== prevImage) {
|
|
247
|
+
setPrevImage(user == null ? void 0 : user.image);
|
|
248
|
+
setImgError(false);
|
|
381
249
|
}
|
|
382
|
-
if (!
|
|
250
|
+
if (!isAuthenticated || loading) {
|
|
383
251
|
return /* @__PURE__ */ jsxs(
|
|
384
252
|
"button",
|
|
385
253
|
{
|
|
@@ -388,7 +256,7 @@ function SanvikaAccountButton({
|
|
|
388
256
|
if (onLoginClick) {
|
|
389
257
|
onLoginClick();
|
|
390
258
|
} else {
|
|
391
|
-
|
|
259
|
+
window.location.href = "https://accounts.sanvikaproduction.com";
|
|
392
260
|
}
|
|
393
261
|
},
|
|
394
262
|
"aria-label": "Login or Sign Up",
|
|
@@ -405,15 +273,15 @@ function SanvikaAccountButton({
|
|
|
405
273
|
}
|
|
406
274
|
);
|
|
407
275
|
}
|
|
408
|
-
const displayName = user.firstName || ((
|
|
276
|
+
const displayName = user.firstName || ((_b = user.mobile) == null ? void 0 : _b.slice(-4)) || "Me";
|
|
409
277
|
const imageSrc = !imgError && user.image ? user.image : DEFAULT_AVATAR_SVG;
|
|
410
278
|
const handleProfileClick = () => {
|
|
411
279
|
if (onProfileClick) return onProfileClick();
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
280
|
+
window.location.href = "https://accounts.sanvikaproduction.com/dashboard";
|
|
281
|
+
};
|
|
282
|
+
const handleLogout = async () => {
|
|
283
|
+
await logout(false);
|
|
284
|
+
setDropdownOpen(false);
|
|
417
285
|
};
|
|
418
286
|
return /* @__PURE__ */ jsxs("div", { ref: wrapperRef, className: `snvk-wrapper ${className}`, children: [
|
|
419
287
|
/* @__PURE__ */ jsxs(
|
|
@@ -468,7 +336,7 @@ function SanvikaAccountButton({
|
|
|
468
336
|
/* @__PURE__ */ jsxs(
|
|
469
337
|
"a",
|
|
470
338
|
{
|
|
471
|
-
href:
|
|
339
|
+
href: "https://accounts.sanvikaproduction.com/dashboard",
|
|
472
340
|
className: "snvk-dropdownItem",
|
|
473
341
|
role: "menuitem",
|
|
474
342
|
onClick: () => setDropdownOpen(false),
|
|
@@ -477,18 +345,47 @@ function SanvikaAccountButton({
|
|
|
477
345
|
/* @__PURE__ */ jsx2("span", { children: "Dashboard" })
|
|
478
346
|
]
|
|
479
347
|
}
|
|
348
|
+
),
|
|
349
|
+
/* @__PURE__ */ jsx2("div", { className: "snvk-divider" }),
|
|
350
|
+
/* @__PURE__ */ jsxs(
|
|
351
|
+
"button",
|
|
352
|
+
{
|
|
353
|
+
className: "snvk-dropdownItem",
|
|
354
|
+
role: "menuitem",
|
|
355
|
+
onClick: handleLogout,
|
|
356
|
+
children: [
|
|
357
|
+
/* @__PURE__ */ jsxs(
|
|
358
|
+
"svg",
|
|
359
|
+
{
|
|
360
|
+
width: "15",
|
|
361
|
+
height: "15",
|
|
362
|
+
viewBox: "0 0 24 24",
|
|
363
|
+
fill: "none",
|
|
364
|
+
stroke: "currentColor",
|
|
365
|
+
strokeWidth: "2",
|
|
366
|
+
strokeLinecap: "round",
|
|
367
|
+
children: [
|
|
368
|
+
/* @__PURE__ */ jsx2("path", { d: "M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4" }),
|
|
369
|
+
/* @__PURE__ */ jsx2("polyline", { points: "16 17 21 12 16 7" }),
|
|
370
|
+
/* @__PURE__ */ jsx2("line", { x1: "21", y1: "12", x2: "9", y2: "12" })
|
|
371
|
+
]
|
|
372
|
+
}
|
|
373
|
+
),
|
|
374
|
+
/* @__PURE__ */ jsx2("span", { children: "Logout" })
|
|
375
|
+
]
|
|
376
|
+
}
|
|
480
377
|
)
|
|
481
378
|
] })
|
|
482
379
|
] });
|
|
483
380
|
}
|
|
381
|
+
function SanvikaAccountButton(props) {
|
|
382
|
+
return /* @__PURE__ */ jsx2(SanvikaAccountButtonErrorBoundary, { children: /* @__PURE__ */ jsx2(SanvikaAccountButtonContent, { ...props }) });
|
|
383
|
+
}
|
|
484
384
|
export {
|
|
485
385
|
DEFAULT_AVATAR_SVG,
|
|
486
386
|
STORAGE_KEYS,
|
|
487
387
|
SanvikaAccountButton,
|
|
488
388
|
SanvikaAuthContext,
|
|
489
389
|
SanvikaAuthProvider,
|
|
490
|
-
decodeToken,
|
|
491
|
-
ensureTokenFresh,
|
|
492
|
-
scheduleTokenRefresh,
|
|
493
390
|
useSanvikaAuth
|
|
494
391
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanvika/auth",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.22",
|
|
4
4
|
"description": "Sanvika Auth SDK — React components and hooks for Sanvika SSO integration",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -29,7 +29,6 @@
|
|
|
29
29
|
"sanvika",
|
|
30
30
|
"auth",
|
|
31
31
|
"sso",
|
|
32
|
-
"oauth",
|
|
33
32
|
"react",
|
|
34
33
|
"nextjs"
|
|
35
34
|
],
|