@sanvika/auth 2.6.1 → 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.
Files changed (2) hide show
  1. package/dist/server.js +32 -0
  2. package/package.json +1 -1
package/dist/server.js CHANGED
@@ -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.1",
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",