@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 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://accounts.sanvikaproduction.com";
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://accounts.sanvikaproduction.com";
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://accounts.sanvikaproduction.com/authorize";
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://accounts.sanvikaproduction.com/dashboard";
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://accounts.sanvikaproduction.com";
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,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanvika/auth",
3
- "version": "2.6.0",
3
+ "version": "2.7.0",
4
4
  "description": "Sanvika Auth SDK — React components/hooks + server-side token verification and user proxy",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",