@oxyhq/services 5.17.1 → 5.17.4
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/lib/commonjs/ui/components/OxyProvider.js +5 -12
- package/lib/commonjs/ui/components/OxyProvider.js.map +1 -1
- package/lib/commonjs/ui/context/OxyContext.js +34 -15
- package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
- package/lib/commonjs/ui/context/OxyContextBase.js +21 -0
- package/lib/commonjs/ui/context/OxyContextBase.js.map +1 -0
- package/lib/commonjs/ui/context/hooks/useAuthOperations.js +28 -11
- package/lib/commonjs/ui/context/hooks/useAuthOperations.js.map +1 -1
- package/lib/commonjs/ui/hooks/queries/useAccountQueries.js +8 -8
- package/lib/commonjs/ui/hooks/queries/useAccountQueries.js.map +1 -1
- package/lib/commonjs/ui/hooks/queries/useSecurityQueries.js +3 -3
- package/lib/commonjs/ui/hooks/queries/useSecurityQueries.js.map +1 -1
- package/lib/commonjs/ui/hooks/queries/useServicesQueries.js +6 -6
- package/lib/commonjs/ui/hooks/queries/useServicesQueries.js.map +1 -1
- package/lib/module/ui/components/OxyProvider.js +5 -12
- package/lib/module/ui/components/OxyProvider.js.map +1 -1
- package/lib/module/ui/context/OxyContext.js +23 -13
- package/lib/module/ui/context/OxyContext.js.map +1 -1
- package/lib/module/ui/context/OxyContextBase.js +16 -0
- package/lib/module/ui/context/OxyContextBase.js.map +1 -0
- package/lib/module/ui/context/hooks/useAuthOperations.js +28 -11
- package/lib/module/ui/context/hooks/useAuthOperations.js.map +1 -1
- package/lib/module/ui/hooks/queries/useAccountQueries.js +1 -1
- package/lib/module/ui/hooks/queries/useAccountQueries.js.map +1 -1
- package/lib/module/ui/hooks/queries/useSecurityQueries.js +1 -1
- package/lib/module/ui/hooks/queries/useSecurityQueries.js.map +1 -1
- package/lib/module/ui/hooks/queries/useServicesQueries.js +1 -1
- package/lib/module/ui/hooks/queries/useServicesQueries.js.map +1 -1
- package/lib/typescript/ui/components/OxyProvider.d.ts.map +1 -1
- package/lib/typescript/ui/context/OxyContext.d.ts +2 -94
- package/lib/typescript/ui/context/OxyContext.d.ts.map +1 -1
- package/lib/typescript/ui/context/OxyContextBase.d.ts +99 -0
- package/lib/typescript/ui/context/OxyContextBase.d.ts.map +1 -0
- package/lib/typescript/ui/context/hooks/useAuthOperations.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/ui/components/OxyProvider.tsx +7 -13
- package/src/ui/context/OxyContext.tsx +27 -88
- package/src/ui/context/OxyContextBase.tsx +95 -0
- package/src/ui/context/hooks/useAuthOperations.ts +35 -19
- package/src/ui/hooks/queries/useAccountQueries.ts +1 -1
- package/src/ui/hooks/queries/useSecurityQueries.ts +1 -1
- package/src/ui/hooks/queries/useServicesQueries.ts +1 -1
|
@@ -96,18 +96,18 @@ export const useAuthOperations = ({
|
|
|
96
96
|
const USER_ID_STORAGE_KEY = 'oxy_user_id';
|
|
97
97
|
|
|
98
98
|
// Online-only sign-in: require backend availability
|
|
99
|
-
// First,
|
|
99
|
+
// First, look up the user by public key to get the correct userId
|
|
100
|
+
// This ensures we always use the userId that matches the current identity's public key
|
|
100
101
|
let userId: string | null = null;
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
102
|
+
|
|
103
|
+
// Always verify the userId matches the current public key
|
|
104
|
+
// This prevents auth failures when identity has changed
|
|
105
|
+
const userLookup = await oxyServices.getUserByPublicKey(publicKey);
|
|
106
|
+
userId = userLookup.id;
|
|
107
|
+
|
|
108
|
+
// Update stored userId to match current identity
|
|
109
|
+
if (storage && userId) {
|
|
110
|
+
await storage.setItem(USER_ID_STORAGE_KEY, userId).catch(() => {});
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
const challengeResponse = await oxyServices.requestChallenge(userId);
|
|
@@ -126,14 +126,30 @@ export const useAuthOperations = ({
|
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
// Verify and create session using userId
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
129
|
+
let sessionResponse;
|
|
130
|
+
try {
|
|
131
|
+
sessionResponse = await oxyServices.verifyChallenge(
|
|
132
|
+
userId,
|
|
133
|
+
challenge,
|
|
134
|
+
signature,
|
|
135
|
+
timestamp,
|
|
136
|
+
deviceName,
|
|
137
|
+
deviceFingerprint,
|
|
138
|
+
);
|
|
139
|
+
} catch (verifyError) {
|
|
140
|
+
// Add detailed logging for 401 errors to help diagnose auth failures
|
|
141
|
+
if (__DEV__) {
|
|
142
|
+
console.error('[useAuthOperations] verifyChallenge failed:', {
|
|
143
|
+
error: verifyError,
|
|
144
|
+
userId,
|
|
145
|
+
challengeLength: challenge?.length,
|
|
146
|
+
signatureLength: signature?.length,
|
|
147
|
+
timestamp,
|
|
148
|
+
timeSinceChallenge: Date.now() - timestamp,
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
throw verifyError;
|
|
152
|
+
}
|
|
137
153
|
|
|
138
154
|
// Store tokens immediately (no extra round-trip)
|
|
139
155
|
oxyServices.setTokens(sessionResponse.accessToken, sessionResponse.refreshToken);
|
|
@@ -2,7 +2,7 @@ import { useQuery, useQueries } from '@tanstack/react-query';
|
|
|
2
2
|
import type { User } from '../../../models/interfaces';
|
|
3
3
|
import type { OxyServices } from '../../../core';
|
|
4
4
|
import { queryKeys } from './queryKeys';
|
|
5
|
-
import { useOxy } from '../../context/
|
|
5
|
+
import { useOxy } from '../../context/OxyContextBase';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Get user profile by session ID
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useQuery } from '@tanstack/react-query';
|
|
2
2
|
import { queryKeys } from './queryKeys';
|
|
3
|
-
import { useOxy } from '../../context/
|
|
3
|
+
import { useOxy } from '../../context/OxyContextBase';
|
|
4
4
|
import type { SecurityActivity, SecurityEventType } from '../../../models/interfaces';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useQuery } from '@tanstack/react-query';
|
|
2
2
|
import type { ClientSession } from '../../../models/session';
|
|
3
3
|
import { queryKeys } from './queryKeys';
|
|
4
|
-
import { useOxy } from '../../context/
|
|
4
|
+
import { useOxy } from '../../context/OxyContextBase';
|
|
5
5
|
import { fetchSessionsWithFallback, mapSessionsToClient } from '../../utils/sessionHelpers';
|
|
6
6
|
|
|
7
7
|
/**
|