@oxyhq/services 6.3.0 → 6.4.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 (63) hide show
  1. package/lib/commonjs/index.js +0 -39
  2. package/lib/commonjs/index.js.map +1 -1
  3. package/lib/commonjs/ui/context/OxyContext.js +1 -0
  4. package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
  5. package/lib/commonjs/ui/hooks/mutations/useAccountMutations.js +5 -5
  6. package/lib/commonjs/ui/hooks/mutations/useAccountMutations.js.map +1 -1
  7. package/lib/commonjs/ui/hooks/queries/useAccountQueries.js +2 -2
  8. package/lib/commonjs/ui/hooks/queries/useAccountQueries.js.map +1 -1
  9. package/lib/commonjs/ui/hooks/queries/useServicesQueries.js +2 -2
  10. package/lib/commonjs/ui/hooks/queries/useServicesQueries.js.map +1 -1
  11. package/lib/commonjs/ui/hooks/useSessionSocket.js +22 -38
  12. package/lib/commonjs/ui/hooks/useSessionSocket.js.map +1 -1
  13. package/lib/commonjs/ui/utils/avatarUtils.js +2 -2
  14. package/lib/commonjs/ui/utils/avatarUtils.js.map +1 -1
  15. package/lib/module/index.js +0 -2
  16. package/lib/module/index.js.map +1 -1
  17. package/lib/module/ui/context/OxyContext.js +1 -0
  18. package/lib/module/ui/context/OxyContext.js.map +1 -1
  19. package/lib/module/ui/hooks/mutations/useAccountMutations.js +1 -1
  20. package/lib/module/ui/hooks/mutations/useAccountMutations.js.map +1 -1
  21. package/lib/module/ui/hooks/queries/useAccountQueries.js +1 -1
  22. package/lib/module/ui/hooks/queries/useAccountQueries.js.map +1 -1
  23. package/lib/module/ui/hooks/queries/useServicesQueries.js +1 -1
  24. package/lib/module/ui/hooks/queries/useServicesQueries.js.map +1 -1
  25. package/lib/module/ui/hooks/useSessionSocket.js +22 -38
  26. package/lib/module/ui/hooks/useSessionSocket.js.map +1 -1
  27. package/lib/module/ui/utils/avatarUtils.js +1 -1
  28. package/lib/module/ui/utils/avatarUtils.js.map +1 -1
  29. package/lib/typescript/commonjs/index.d.ts +0 -2
  30. package/lib/typescript/commonjs/index.d.ts.map +1 -1
  31. package/lib/typescript/commonjs/ui/context/OxyContext.d.ts.map +1 -1
  32. package/lib/typescript/commonjs/ui/hooks/mutations/useAccountMutations.d.ts.map +1 -1
  33. package/lib/typescript/commonjs/ui/hooks/queries/useServicesQueries.d.ts.map +1 -1
  34. package/lib/typescript/commonjs/ui/hooks/useSessionSocket.d.ts +2 -1
  35. package/lib/typescript/commonjs/ui/hooks/useSessionSocket.d.ts.map +1 -1
  36. package/lib/typescript/commonjs/ui/utils/avatarUtils.d.ts +1 -2
  37. package/lib/typescript/commonjs/ui/utils/avatarUtils.d.ts.map +1 -1
  38. package/lib/typescript/module/index.d.ts +0 -2
  39. package/lib/typescript/module/index.d.ts.map +1 -1
  40. package/lib/typescript/module/ui/context/OxyContext.d.ts.map +1 -1
  41. package/lib/typescript/module/ui/hooks/mutations/useAccountMutations.d.ts.map +1 -1
  42. package/lib/typescript/module/ui/hooks/queries/useServicesQueries.d.ts.map +1 -1
  43. package/lib/typescript/module/ui/hooks/useSessionSocket.d.ts +2 -1
  44. package/lib/typescript/module/ui/hooks/useSessionSocket.d.ts.map +1 -1
  45. package/lib/typescript/module/ui/utils/avatarUtils.d.ts +1 -2
  46. package/lib/typescript/module/ui/utils/avatarUtils.d.ts.map +1 -1
  47. package/package.json +1 -1
  48. package/src/index.ts +0 -7
  49. package/src/ui/context/OxyContext.tsx +1 -0
  50. package/src/ui/hooks/mutations/useAccountMutations.ts +1 -1
  51. package/src/ui/hooks/queries/useAccountQueries.ts +1 -1
  52. package/src/ui/hooks/queries/useServicesQueries.ts +1 -1
  53. package/src/ui/hooks/useSessionSocket.ts +24 -37
  54. package/src/ui/utils/avatarUtils.ts +2 -3
  55. package/lib/commonjs/ui/utils/authHelpers.js +0 -164
  56. package/lib/commonjs/ui/utils/authHelpers.js.map +0 -1
  57. package/lib/module/ui/utils/authHelpers.js +0 -154
  58. package/lib/module/ui/utils/authHelpers.js.map +0 -1
  59. package/lib/typescript/commonjs/ui/utils/authHelpers.d.ts +0 -99
  60. package/lib/typescript/commonjs/ui/utils/authHelpers.d.ts.map +0 -1
  61. package/lib/typescript/module/ui/utils/authHelpers.d.ts +0 -99
  62. package/lib/typescript/module/ui/utils/authHelpers.d.ts.map +0 -1
  63. package/src/ui/utils/authHelpers.ts +0 -183
@@ -1 +1 @@
1
- {"version":3,"file":"OxyContext.d.ts","sourceRoot":"","sources":["../../../../../src/ui/context/OxyContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAQZ,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAElD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAKjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAMvE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAStD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IAClB,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,eAAe,EAAE,OAAO,CAAC;IACzB,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,OAAO,CAAC;IACtB,cAAc,EAAE,OAAO,CAAC;IACxB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,uBAAuB,EAAE,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC,UAAU,CAAC,CAAC;IAC9E,mBAAmB,EAAE,MAAM,CAAC;IAC5B,yBAAyB,EAAE,MAA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AAE,mEAgB7D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,GAAI,UAAU;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,+DAY9D,CAAC"}
@@ -6,9 +6,10 @@ interface UseSessionSocketProps {
6
6
  logout: () => Promise<void>;
7
7
  clearSessionState: () => Promise<void>;
8
8
  baseURL: string;
9
+ getAccessToken: () => string | null;
9
10
  onRemoteSignOut?: () => void;
10
11
  onSessionRemoved?: (sessionId: string) => void;
11
12
  }
12
- export declare function useSessionSocket({ userId, activeSessionId, currentDeviceId, refreshSessions, logout, clearSessionState, baseURL, onRemoteSignOut, onSessionRemoved }: UseSessionSocketProps): void;
13
+ export declare function useSessionSocket({ userId, activeSessionId, currentDeviceId, refreshSessions, logout, clearSessionState, baseURL, getAccessToken, onRemoteSignOut, onSessionRemoved }: UseSessionSocketProps): void;
13
14
  export {};
14
15
  //# sourceMappingURL=useSessionSocket.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useSessionSocket.d.ts","sourceRoot":"","sources":["../../../../../src/ui/hooks/useSessionSocket.ts"],"names":[],"mappings":"AAQA,UAAU,qBAAqB;IAC7B,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAClC,eAAe,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAC3C,eAAe,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAC3C,eAAe,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACrC,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,iBAAiB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,CAAC,EAAE,MAAM,IAAI,CAAC;IAC7B,gBAAgB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CAChD;AAED,wBAAgB,gBAAgB,CAAC,EAAE,MAAM,EAAE,eAAe,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,EAAE,iBAAiB,EAAE,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,EAAE,qBAAqB,QAwN3L"}
1
+ {"version":3,"file":"useSessionSocket.d.ts","sourceRoot":"","sources":["../../../../../src/ui/hooks/useSessionSocket.ts"],"names":[],"mappings":"AAQA,UAAU,qBAAqB;IAC7B,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAClC,eAAe,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAC3C,eAAe,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAC3C,eAAe,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACrC,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,iBAAiB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,MAAM,GAAG,IAAI,CAAC;IACpC,eAAe,CAAC,EAAE,MAAM,IAAI,CAAC;IAC7B,gBAAgB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CAChD;AAED,wBAAgB,gBAAgB,CAAC,EAAE,MAAM,EAAE,eAAe,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,EAAE,iBAAiB,EAAE,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,gBAAgB,EAAE,EAAE,qBAAqB,QA0M3M"}
@@ -1,5 +1,4 @@
1
- import type { OxyServices } from '@oxyhq/core';
2
- import type { User } from '@oxyhq/core';
1
+ import type { OxyServices, User } from '@oxyhq/core';
3
2
  import { QueryClient } from '@tanstack/react-query';
4
3
  /**
5
4
  * Updates file visibility to public for avatar use.
@@ -1 +1 @@
1
- {"version":3,"file":"avatarUtils.d.ts","sourceRoot":"","sources":["../../../../../src/ui/utils/avatarUtils.ts"],"names":[],"mapp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;;;;;;;;;GAUG;AACH,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,EACtB,WAAW,EAAE,WAAW,EACxB,eAAe,EAAE,MAAM,GAAG,IAAI,EAC9B,WAAW,EAAE,WAAW,EACxB,WAAW,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAChC,OAAO,CAAC,IAAI,CAAC,CA2Bf"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oxyhq/services",
3
- "version": "6.3.0",
3
+ "version": "6.4.0",
4
4
  "description": "OxyHQ Expo/React Native SDK — UI components, screens, and native features",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "module": "lib/module/index.js",
package/src/index.ts CHANGED
@@ -80,13 +80,6 @@ export type {
80
80
  ProfileMutationConfig, GenericMutationConfig,
81
81
  } from './ui/hooks/mutations/mutationFactory';
82
82
 
83
- // Auth helpers
84
- export {
85
- ensureValidToken, withAuthErrorHandling, authenticatedApiCall,
86
- isAuthenticationError, SessionSyncRequiredError, AuthenticationFailedError,
87
- } from './ui/utils/authHelpers';
88
- export type { HandleApiErrorOptions } from './ui/utils/authHelpers';
89
-
90
83
  // Error handlers
91
84
  export {
92
85
  handleAuthError, isInvalidSessionError,
@@ -585,6 +585,7 @@ export const OxyProvider: React.FC<OxyContextProviderProps> = ({
585
585
  logout,
586
586
  clearSessionState,
587
587
  baseURL: oxyServices.getBaseURL(),
588
+ getAccessToken: () => oxyServices.getAccessToken(),
588
589
  onRemoteSignOut: handleRemoteSignOut,
589
590
  onSessionRemoved: handleSessionRemoved,
590
591
  });
@@ -1,11 +1,11 @@
1
1
  import { useMutation, useQueryClient } from '@tanstack/react-query';
2
+ import { authenticatedApiCall } from '@oxyhq/core';
2
3
  import type { User } from '@oxyhq/core';
3
4
  import { queryKeys, invalidateAccountQueries, invalidateUserQueries } from '../queries/queryKeys';
4
5
  import { useOxy } from '../../context/OxyContext';
5
6
  import { toast } from '../../../lib/sonner';
6
7
  import { refreshAvatarInStore } from '../../utils/avatarUtils';
7
8
  import { useAuthStore } from '../../stores/authStore';
8
- import { authenticatedApiCall } from '../../utils/authHelpers';
9
9
 
10
10
  /**
11
11
  * Update user profile with optimistic updates and offline queue support
@@ -1,8 +1,8 @@
1
1
  import { useQuery, useQueries } from '@tanstack/react-query';
2
+ import { authenticatedApiCall } from '@oxyhq/core';
2
3
  import type { User } from '@oxyhq/core';
3
4
  import { queryKeys } from './queryKeys';
4
5
  import { useOxy } from '../../context/OxyContext';
5
- import { authenticatedApiCall } from '../../utils/authHelpers';
6
6
 
7
7
  /**
8
8
  * Get user profile by session ID
@@ -1,9 +1,9 @@
1
1
  import { useQuery } from '@tanstack/react-query';
2
+ import { authenticatedApiCall } from '@oxyhq/core';
2
3
  import type { ClientSession } from '@oxyhq/core';
3
4
  import { queryKeys } from './queryKeys';
4
5
  import { useOxy } from '../../context/OxyContext';
5
6
  import { fetchSessionsWithFallback, mapSessionsToClient } from '../../utils/sessionHelpers';
6
- import { authenticatedApiCall } from '../../utils/authHelpers';
7
7
 
8
8
  /**
9
9
  * Get all active sessions for the current user
@@ -14,15 +14,15 @@ interface UseSessionSocketProps {
14
14
  logout: () => Promise<void>;
15
15
  clearSessionState: () => Promise<void>;
16
16
  baseURL: string;
17
+ getAccessToken: () => string | null;
17
18
  onRemoteSignOut?: () => void;
18
19
  onSessionRemoved?: (sessionId: string) => void;
19
20
  }
20
21
 
21
- export function useSessionSocket({ userId, activeSessionId, currentDeviceId, refreshSessions, logout, clearSessionState, baseURL, onRemoteSignOut, onSessionRemoved }: UseSessionSocketProps) {
22
+ export function useSessionSocket({ userId, activeSessionId, currentDeviceId, refreshSessions, logout, clearSessionState, baseURL, getAccessToken, onRemoteSignOut, onSessionRemoved }: UseSessionSocketProps) {
22
23
  const socketRef = useRef<any>(null);
23
- const joinedRoomRef = useRef<string | null>(null);
24
-
25
- // Store callbacks in refs to avoid re-joining when they change
24
+
25
+ // Store callbacks in refs to avoid reconnecting when they change
26
26
  const refreshSessionsRef = useRef(refreshSessions);
27
27
  const logoutRef = useRef(logout);
28
28
  const clearSessionStateRef = useRef(clearSessionState);
@@ -30,6 +30,7 @@ export function useSessionSocket({ userId, activeSessionId, currentDeviceId, ref
30
30
  const onSessionRemovedRef = useRef(onSessionRemoved);
31
31
  const activeSessionIdRef = useRef(activeSessionId);
32
32
  const currentDeviceIdRef = useRef(currentDeviceId);
33
+ const getAccessTokenRef = useRef(getAccessToken);
33
34
 
34
35
  // Update refs when callbacks change
35
36
  useEffect(() => {
@@ -40,42 +41,36 @@ export function useSessionSocket({ userId, activeSessionId, currentDeviceId, ref
40
41
  onSessionRemovedRef.current = onSessionRemoved;
41
42
  activeSessionIdRef.current = activeSessionId;
42
43
  currentDeviceIdRef.current = currentDeviceId;
43
- }, [refreshSessions, logout, clearSessionState, onRemoteSignOut, onSessionRemoved, activeSessionId, currentDeviceId]);
44
+ getAccessTokenRef.current = getAccessToken;
45
+ }, [refreshSessions, logout, clearSessionState, onRemoteSignOut, onSessionRemoved, activeSessionId, currentDeviceId, getAccessToken]);
44
46
 
45
47
  useEffect(() => {
46
48
  if (!userId || !baseURL) {
47
49
  // Clean up if userId or baseURL becomes invalid
48
- if (socketRef.current && joinedRoomRef.current) {
49
- socketRef.current.emit('leave', { userId: joinedRoomRef.current });
50
- joinedRoomRef.current = null;
50
+ if (socketRef.current) {
51
+ socketRef.current.disconnect();
52
+ socketRef.current = null;
51
53
  }
52
54
  return;
53
55
  }
54
56
 
55
- const roomId = `user:${userId}`;
56
-
57
- // Only create socket if it doesn't exist
58
- if (!socketRef.current) {
59
- socketRef.current = io(baseURL, {
60
- transports: ['websocket'],
61
- });
57
+ // Disconnect previous socket if switching users
58
+ if (socketRef.current) {
59
+ socketRef.current.disconnect();
60
+ socketRef.current = null;
62
61
  }
63
- const socket = socketRef.current;
64
62
 
65
- // Only join if we haven't already joined this room
66
- if (joinedRoomRef.current !== roomId) {
67
- // Leave previous room if switching users
68
- if (joinedRoomRef.current) {
69
- socket.emit('leave', { userId: joinedRoomRef.current });
70
- }
71
-
72
- socket.emit('join', { userId: roomId });
73
- joinedRoomRef.current = roomId;
74
-
75
- debug.log('Emitting join for room:', roomId);
76
- }
63
+ // Connect with auth token; use callback so reconnections get a fresh token
64
+ socketRef.current = io(baseURL, {
65
+ transports: ['websocket'],
66
+ auth: (cb) => {
67
+ const token = getAccessTokenRef.current();
68
+ cb({ token: token ?? '' });
69
+ },
70
+ });
71
+ const socket = socketRef.current;
77
72
 
78
- // Set up event handlers (only once per socket instance)
73
+ // Server auto-joins the user to `user:<userId>` room on connection
79
74
  const handleConnect = () => {
80
75
  debug.log('Socket connected:', socket.id);
81
76
  };
@@ -222,14 +217,6 @@ export function useSessionSocket({ userId, activeSessionId, currentDeviceId, ref
222
217
  return () => {
223
218
  socket.off('connect', handleConnect);
224
219
  socket.off('session_update', handleSessionUpdate);
225
-
226
- // Only leave on unmount if we're still in this room
227
- if (joinedRoomRef.current === roomId) {
228
- socket.emit('leave', { userId: roomId });
229
- joinedRoomRef.current = null;
230
- }
231
-
232
- // Disconnect the socket to prevent leaked connections
233
220
  socket.disconnect();
234
221
  socketRef.current = null;
235
222
  };
@@ -1,10 +1,9 @@
1
- import type { OxyServices } from '@oxyhq/core';
2
- import type { User } from '@oxyhq/core';
1
+ import { authenticatedApiCall } from '@oxyhq/core';
2
+ import type { OxyServices, User } from '@oxyhq/core';
3
3
  import { useAccountStore } from '../stores/accountStore';
4
4
  import { useAuthStore } from '../stores/authStore';
5
5
  import { QueryClient } from '@tanstack/react-query';
6
6
  import { queryKeys, invalidateUserQueries, invalidateAccountQueries } from '../hooks/queries/queryKeys';
7
- import { authenticatedApiCall } from './authHelpers';
8
7
 
9
8
  /**
10
9
  * Updates file visibility to public for avatar use.
@@ -1,164 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.SessionSyncRequiredError = exports.AuthenticationFailedError = void 0;
7
- exports.authenticatedApiCall = authenticatedApiCall;
8
- exports.ensureValidToken = ensureValidToken;
9
- exports.isAuthenticationError = isAuthenticationError;
10
- exports.withAuthErrorHandling = withAuthErrorHandling;
11
- /**
12
- * Authentication helper utilities to reduce code duplication across hooks and utilities.
13
- * These functions handle common token validation and authentication error patterns.
14
- */
15
-
16
- /**
17
- * Error thrown when session sync is required
18
- */
19
- class SessionSyncRequiredError extends Error {
20
- constructor(message = 'Session needs to be synced. Please try again.') {
21
- super(message);
22
- this.name = 'SessionSyncRequiredError';
23
- }
24
- }
25
-
26
- /**
27
- * Error thrown when authentication fails
28
- */
29
- exports.SessionSyncRequiredError = SessionSyncRequiredError;
30
- class AuthenticationFailedError extends Error {
31
- constructor(message = 'Authentication failed. Please sign in again.') {
32
- super(message);
33
- this.name = 'AuthenticationFailedError';
34
- }
35
- }
36
-
37
- /**
38
- * Ensures a valid token exists before making authenticated API calls.
39
- * If no valid token exists and an active session ID is available,
40
- * attempts to refresh the token using the session.
41
- *
42
- * @param oxyServices - The OxyServices instance
43
- * @param activeSessionId - The active session ID (if available)
44
- * @throws {SessionSyncRequiredError} If the session needs to be synced (offline session)
45
- * @throws {Error} If token refresh fails for other reasons
46
- *
47
- * @example
48
- * ```ts
49
- * // In a mutation or query function:
50
- * await ensureValidToken(oxyServices, activeSessionId);
51
- * return await oxyServices.updateProfile(updates);
52
- * ```
53
- */
54
- exports.AuthenticationFailedError = AuthenticationFailedError;
55
- async function ensureValidToken(oxyServices, activeSessionId) {
56
- if (oxyServices.hasValidToken() || !activeSessionId) {
57
- return;
58
- }
59
- try {
60
- await oxyServices.getTokenBySession(activeSessionId);
61
- } catch (tokenError) {
62
- const errorMessage = tokenError instanceof Error ? tokenError.message : String(tokenError);
63
- if (errorMessage.includes('AUTH_REQUIRED_OFFLINE_SESSION') || errorMessage.includes('offline')) {
64
- throw new SessionSyncRequiredError();
65
- }
66
- throw tokenError;
67
- }
68
- }
69
-
70
- /**
71
- * Options for handling API authentication errors
72
- */
73
-
74
- /**
75
- * Checks if an error is an authentication error (401 or auth-related message)
76
- *
77
- * @param error - The error to check
78
- * @returns True if the error is an authentication error
79
- */
80
- function isAuthenticationError(error) {
81
- if (!error || typeof error !== 'object') {
82
- return false;
83
- }
84
- const errorObj = error;
85
- const errorMessage = errorObj.message || '';
86
- const status = errorObj.status || errorObj.response?.status;
87
- return status === 401 || errorMessage.includes('Authentication required') || errorMessage.includes('Invalid or missing authorization header');
88
- }
89
-
90
- /**
91
- * Wraps an API call with authentication error handling.
92
- * If an authentication error occurs, it can optionally attempt to sync the session and retry.
93
- *
94
- * @param apiCall - The API call function to execute
95
- * @param options - Optional error handling configuration
96
- * @returns The result of the API call
97
- * @throws {AuthenticationFailedError} If authentication fails and cannot be recovered
98
- * @throws {Error} If the API call fails for non-auth reasons
99
- *
100
- * @example
101
- * ```ts
102
- * // Simple usage:
103
- * const result = await withAuthErrorHandling(
104
- * () => oxyServices.updateProfile(updates)
105
- * );
106
- *
107
- * // With retry on auth failure:
108
- * const result = await withAuthErrorHandling(
109
- * () => oxyServices.updateProfile(updates),
110
- * { syncSession, activeSessionId, oxyServices }
111
- * );
112
- * ```
113
- */
114
- async function withAuthErrorHandling(apiCall, options) {
115
- try {
116
- return await apiCall();
117
- } catch (error) {
118
- if (!isAuthenticationError(error)) {
119
- throw error;
120
- }
121
-
122
- // If we have sync capabilities, try to recover
123
- if (options?.syncSession && options?.activeSessionId && options?.oxyServices) {
124
- try {
125
- await options.syncSession();
126
- await options.oxyServices.getTokenBySession(options.activeSessionId);
127
- // Retry the API call after refreshing token
128
- return await apiCall();
129
- } catch {
130
- throw new AuthenticationFailedError();
131
- }
132
- }
133
- throw new AuthenticationFailedError();
134
- }
135
- }
136
-
137
- /**
138
- * Combines token validation and auth error handling for a complete authenticated API call.
139
- * This is the recommended helper for most authenticated API operations.
140
- *
141
- * @param oxyServices - The OxyServices instance
142
- * @param activeSessionId - The active session ID
143
- * @param apiCall - The API call function to execute
144
- * @param syncSession - Optional callback to sync session on auth failure
145
- * @returns The result of the API call
146
- *
147
- * @example
148
- * ```ts
149
- * return await authenticatedApiCall(
150
- * oxyServices,
151
- * activeSessionId,
152
- * () => oxyServices.updateProfile(updates)
153
- * );
154
- * ```
155
- */
156
- async function authenticatedApiCall(oxyServices, activeSessionId, apiCall, syncSession) {
157
- await ensureValidToken(oxyServices, activeSessionId);
158
- return withAuthErrorHandling(apiCall, {
159
- syncSession,
160
- activeSessionId,
161
- oxyServices
162
- });
163
- }
164
- //# sourceMappingURL=authHelpers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["SessionSyncRequiredError","Error","constructor","message","name","exports","AuthenticationFailedError","ensureValidToken","oxyServices","activeSessionId","hasValidToken","getTokenBySession","tokenError","errorMessage","String","includes","isAuthenticationError","error","errorObj","status","response","withAuthErrorHandling","apiCall","options","syncSession","authenticatedApiCall"],"sourceRoot":"../../../../src","sources":["ui/utils/authHelpers.ts"],"mappings":";;;;;;;;;;AAAA;AACA;AACA;AACA;;AAIA;AACA;AACA;AACO,MAAMA,wBAAwB,SAASC,KAAK,CAAC;EAClDC,WAAWA,CAACC,OAAO,GAAG,+CAA+C,EAAE;IACrE,KAAK,CAACA,OAAO,CAAC;IACd,IAAI,CAACC,IAAI,GAAG,0BAA0B;EACxC;AACF;;AAEA;AACA;AACA;AAFAC,OAAA,CAAAL,wBAAA,GAAAA,wBAAA;AAGO,MAAMM,yBAAyB,SAASL,KAAK,CAAC;EACnDC,WAAWA,CAACC,OAAO,GAAG,8CAA8C,EAAE;IACpE,KAAK,CAACA,OAAO,CAAC;IACd,IAAI,CAACC,IAAI,GAAG,2BAA2B;EACzC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAhBAC,OAAA,CAAAC,yBAAA,GAAAA,yBAAA;AAiBO,eAAeC,gBAAgBA,CACpCC,WAAwB,EACxBC,eAA0C,EAC3B;EACf,IAAID,WAAW,CAACE,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MACjC,MAAMA,KAAK;IACb;;IAEA;IACA,IAAIM,OAAO,EAAEC,WAAW,IAAID,OAAO,EAAEd,eAAe,IAAIc,OAAO,EAAEf,WAAW,EAAE;MAC5E,IAAI;QACF,MAAMe,OAAO,CAACC,WAAW,CAAC,CAAC;QAC3B,MAAMD,OAAO,CAACf,WAAW,CAACG,iBAAiB,CAACY,OAAO,CAACd,eAAe,CAAC;QACpE;QACA,OAAO,MAAMa,OAAO,CAAC,CAAC;MACxB,CAAC,CAAC,MAAM;QACN,MAAM,IAAIhB,yBAAyB,CAAC,CAAC;MACvC;IACF;IAEA,MAAM,IAAIA,yBAAyB,CAAC,CAAC;EACvC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAemB,oBAAoBA,CACxCjB,WAAwB,EACxBC,eAA0C,EAC1Ca,OAAyB,EACzBE,WAAoC,EACxB;EACZ,MAAMjB,gBAAgB,CAACC,WAAW,EAAEC,eAAe,CAAC;EAEpD,OAAOY,qBAAqB,CAACC,OAAO,EAAE;IACpCE,WAAW;IACXf,eAAe;IACfD;EACF,CAAC,CAAC;AACJ","ignoreList":[]}
@@ -1,154 +0,0 @@
1
- "use strict";
2
-
3
- /**
4
- * Authentication helper utilities to reduce code duplication across hooks and utilities.
5
- * These functions handle common token validation and authentication error patterns.
6
- */
7
-
8
- /**
9
- * Error thrown when session sync is required
10
- */
11
- export class SessionSyncRequiredError extends Error {
12
- constructor(message = 'Session needs to be synced. Please try again.') {
13
- super(message);
14
- this.name = 'SessionSyncRequiredError';
15
- }
16
- }
17
-
18
- /**
19
- * Error thrown when authentication fails
20
- */
21
- export class AuthenticationFailedError extends Error {
22
- constructor(message = 'Authentication failed. Please sign in again.') {
23
- super(message);
24
- this.name = 'AuthenticationFailedError';
25
- }
26
- }
27
-
28
- /**
29
- * Ensures a valid token exists before making authenticated API calls.
30
- * If no valid token exists and an active session ID is available,
31
- * attempts to refresh the token using the session.
32
- *
33
- * @param oxyServices - The OxyServices instance
34
- * @param activeSessionId - The active session ID (if available)
35
- * @throws {SessionSyncRequiredError} If the session needs to be synced (offline session)
36
- * @throws {Error} If token refresh fails for other reasons
37
- *
38
- * @example
39
- * ```ts
40
- * // In a mutation or query function:
41
- * await ensureValidToken(oxyServices, activeSessionId);
42
- * return await oxyServices.updateProfile(updates);
43
- * ```
44
- */
45
- export async function ensureValidToken(oxyServices, activeSessionId) {
46
- if (oxyServices.hasValidToken() || !activeSessionId) {
47
- return;
48
- }
49
- try {
50
- await oxyServices.getTokenBySession(activeSessionId);
51
- } catch (tokenError) {
52
- const errorMessage = tokenError instanceof Error ? tokenError.message : String(tokenError);
53
- if (errorMessage.includes('AUTH_REQUIRED_OFFLINE_SESSION') || errorMessage.includes('offline')) {
54
- throw new SessionSyncRequiredError();
55
- }
56
- throw tokenError;
57
- }
58
- }
59
-
60
- /**
61
- * Options for handling API authentication errors
62
- */
63
-
64
- /**
65
- * Checks if an error is an authentication error (401 or auth-related message)
66
- *
67
- * @param error - The error to check
68
- * @returns True if the error is an authentication error
69
- */
70
- export function isAuthenticationError(error) {
71
- if (!error || typeof error !== 'object') {
72
- return false;
73
- }
74
- const errorObj = error;
75
- const errorMessage = errorObj.message || '';
76
- const status = errorObj.status || errorObj.response?.status;
77
- return status === 401 || errorMessage.includes('Authentication required') || errorMessage.includes('Invalid or missing authorization header');
78
- }
79
-
80
- /**
81
- * Wraps an API call with authentication error handling.
82
- * If an authentication error occurs, it can optionally attempt to sync the session and retry.
83
- *
84
- * @param apiCall - The API call function to execute
85
- * @param options - Optional error handling configuration
86
- * @returns The result of the API call
87
- * @throws {AuthenticationFailedError} If authentication fails and cannot be recovered
88
- * @throws {Error} If the API call fails for non-auth reasons
89
- *
90
- * @example
91
- * ```ts
92
- * // Simple usage:
93
- * const result = await withAuthErrorHandling(
94
- * () => oxyServices.updateProfile(updates)
95
- * );
96
- *
97
- * // With retry on auth failure:
98
- * const result = await withAuthErrorHandling(
99
- * () => oxyServices.updateProfile(updates),
100
- * { syncSession, activeSessionId, oxyServices }
101
- * );
102
- * ```
103
- */
104
- export async function withAuthErrorHandling(apiCall, options) {
105
- try {
106
- return await apiCall();
107
- } catch (error) {
108
- if (!isAuthenticationError(error)) {
109
- throw error;
110
- }
111
-
112
- // If we have sync capabilities, try to recover
113
- if (options?.syncSession && options?.activeSessionId && options?.oxyServices) {
114
- try {
115
- await options.syncSession();
116
- await options.oxyServices.getTokenBySession(options.activeSessionId);
117
- // Retry the API call after refreshing token
118
- return await apiCall();
119
- } catch {
120
- throw new AuthenticationFailedError();
121
- }
122
- }
123
- throw new AuthenticationFailedError();
124
- }
125
- }
126
-
127
- /**
128
- * Combines token validation and auth error handling for a complete authenticated API call.
129
- * This is the recommended helper for most authenticated API operations.
130
- *
131
- * @param oxyServices - The OxyServices instance
132
- * @param activeSessionId - The active session ID
133
- * @param apiCall - The API call function to execute
134
- * @param syncSession - Optional callback to sync session on auth failure
135
- * @returns The result of the API call
136
- *
137
- * @example
138
- * ```ts
139
- * return await authenticatedApiCall(
140
- * oxyServices,
141
- * activeSessionId,
142
- * () => oxyServices.updateProfile(updates)
143
- * );
144
- * ```
145
- */
146
- export async function authenticatedApiCall(oxyServices, activeSessionId, apiCall, syncSession) {
147
- await ensureValidToken(oxyServices, activeSessionId);
148
- return withAuthErrorHandling(apiCall, {
149
- syncSession,
150
- activeSessionId,
151
- oxyServices
152
- });
153
- }
154
- //# sourceMappingURL=authHelpers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["SessionSyncRequiredError","Error","constructor","message","name","AuthenticationFailedError","ensureValidToken","oxyServices","activeSessionId","hasValidToken","getTokenBySession","tokenError","errorMessage","String","includes","isAuthenticationError","error","errorObj","status","response","withAuthErrorHandling","apiCall","options","syncSession","authenticatedApiCall"],"sourceRoot":"../../../../src","sources":["ui/utils/authHelpers.ts"],"mappings":";;AAAA;AACA;AACA;AACA;;AAIA;AACA;AACA;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