@sanvika/auth 2.6.0 → 2.7.0
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 +4 -4
- package/dist/server.js +33 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -19,7 +19,7 @@ var DEFAULT_AVATAR_SVG = `data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/200
|
|
|
19
19
|
|
|
20
20
|
// SanvikaAuthProvider.jsx
|
|
21
21
|
import { jsx } from "react/jsx-runtime";
|
|
22
|
-
var S_AUTH_URL = "https://
|
|
22
|
+
var S_AUTH_URL = "https://auth.sanvikaproduction.com";
|
|
23
23
|
var SanvikaAuthContext = createContext(null);
|
|
24
24
|
function randomDeviceId() {
|
|
25
25
|
try {
|
|
@@ -196,7 +196,7 @@ styleInject("@keyframes snvk-shimmer {\n 0% {\n background-position: 200% 0;
|
|
|
196
196
|
|
|
197
197
|
// SanvikaAccountButton.jsx
|
|
198
198
|
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
199
|
-
var S_AUTH_URL2 = "https://
|
|
199
|
+
var S_AUTH_URL2 = "https://auth.sanvikaproduction.com";
|
|
200
200
|
var SanvikaAccountButtonErrorBoundary = class extends Component {
|
|
201
201
|
constructor(props) {
|
|
202
202
|
super(props);
|
|
@@ -304,7 +304,7 @@ function SanvikaAccountButtonContent({
|
|
|
304
304
|
if (onLoginClick) {
|
|
305
305
|
onLoginClick();
|
|
306
306
|
} else {
|
|
307
|
-
window.location.href = "https://
|
|
307
|
+
window.location.href = "https://auth.sanvikaproduction.com/authorize";
|
|
308
308
|
}
|
|
309
309
|
},
|
|
310
310
|
"aria-label": "Login or Sign Up",
|
|
@@ -359,7 +359,7 @@ function SanvikaAccountButtonContent({
|
|
|
359
359
|
const imageSrc = !imgError && user.image ? user.image : DEFAULT_AVATAR_SVG;
|
|
360
360
|
const handleProfileClick = () => {
|
|
361
361
|
if (onProfileClick) return onProfileClick();
|
|
362
|
-
window.location.href = (auth == null ? void 0 : auth.dashboardPath) || "https://
|
|
362
|
+
window.location.href = (auth == null ? void 0 : auth.dashboardPath) || "https://auth.sanvikaproduction.com/dashboard";
|
|
363
363
|
};
|
|
364
364
|
const handleLogout = async () => {
|
|
365
365
|
await logout(false);
|
package/dist/server.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const _authUrl = () => {
|
|
2
2
|
var _a;
|
|
3
|
-
return typeof process !== "undefined" && ((_a = process.env) == null ? void 0 : _a.AUTH_URL) || "https://
|
|
3
|
+
return typeof process !== "undefined" && ((_a = process.env) == null ? void 0 : _a.AUTH_URL) || "https://auth.sanvikaproduction.com";
|
|
4
4
|
};
|
|
5
5
|
const _serviceKey = () => {
|
|
6
6
|
var _a;
|
|
@@ -72,6 +72,36 @@ async function getUserFromAuth(uid) {
|
|
|
72
72
|
return null;
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
|
+
async function getUserDevicesFromAuth(uid) {
|
|
76
|
+
if (!uid) return null;
|
|
77
|
+
try {
|
|
78
|
+
const res = await fetch(`${_authUrl()}/api/devices?uid=${encodeURIComponent(uid)}`, {
|
|
79
|
+
headers: _s2sHeaders(),
|
|
80
|
+
signal: AbortSignal.timeout(5e3)
|
|
81
|
+
});
|
|
82
|
+
if (!res.ok) return null;
|
|
83
|
+
const data = await res.json();
|
|
84
|
+
return data.success ? data.data : null;
|
|
85
|
+
} catch {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
async function revokeDeviceFromAuth(uid, deviceId) {
|
|
90
|
+
if (!uid || !deviceId) return null;
|
|
91
|
+
try {
|
|
92
|
+
const res = await fetch(`${_authUrl()}/api/devices?uid=${encodeURIComponent(uid)}`, {
|
|
93
|
+
method: "DELETE",
|
|
94
|
+
headers: _s2sHeaders(),
|
|
95
|
+
body: JSON.stringify({ deviceId }),
|
|
96
|
+
signal: AbortSignal.timeout(5e3)
|
|
97
|
+
});
|
|
98
|
+
if (!res.ok) return null;
|
|
99
|
+
const data = await res.json();
|
|
100
|
+
return data.success ? data.data : null;
|
|
101
|
+
} catch {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
75
105
|
async function getUserLocationFromAuth(uid) {
|
|
76
106
|
if (!uid) return null;
|
|
77
107
|
try {
|
|
@@ -350,10 +380,12 @@ export {
|
|
|
350
380
|
extractAuthUid,
|
|
351
381
|
extractUserFromToken,
|
|
352
382
|
getUserByMobileFromAuth,
|
|
383
|
+
getUserDevicesFromAuth,
|
|
353
384
|
getUserFromAuth,
|
|
354
385
|
getUserLocationFromAuth,
|
|
355
386
|
listAdminsFromAuth,
|
|
356
387
|
listUsersFromAuth,
|
|
388
|
+
revokeDeviceFromAuth,
|
|
357
389
|
updateUserLocation,
|
|
358
390
|
updateUserProfile,
|
|
359
391
|
verifyAdminFromAuth,
|