@oxyhq/core 1.11.20 → 1.11.22
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/README.md +6 -2
- package/dist/cjs/.tsbuildinfo +1 -1
- package/dist/cjs/mixins/OxyServices.auth.js +14 -1
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/mixins/OxyServices.auth.js +14 -1
- package/dist/types/.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/mixins/OxyServices.auth.ts +16 -1
- package/src/mixins/__tests__/verifyChallenge.test.ts +135 -0
|
@@ -247,7 +247,7 @@ export function OxyServicesAuthMixin(Base) {
|
|
|
247
247
|
*/
|
|
248
248
|
async verifyChallenge(publicKey, challenge, signature, timestamp, deviceName, deviceFingerprint) {
|
|
249
249
|
try {
|
|
250
|
-
|
|
250
|
+
const res = await this.makeRequest('POST', '/auth/verify', {
|
|
251
251
|
publicKey,
|
|
252
252
|
challenge,
|
|
253
253
|
signature,
|
|
@@ -255,6 +255,19 @@ export function OxyServicesAuthMixin(Base) {
|
|
|
255
255
|
deviceName,
|
|
256
256
|
deviceFingerprint,
|
|
257
257
|
}, { cache: false });
|
|
258
|
+
// Plant the freshly-minted tokens, mirroring `claimSessionByToken`.
|
|
259
|
+
// `/auth/verify` returns the first access token (and refresh token) in
|
|
260
|
+
// its body, so installing it here means callers get an authenticated
|
|
261
|
+
// client without a second round-trip — and, critically, without
|
|
262
|
+
// falling back to the bearer-protected `GET /session/token/:sessionId`
|
|
263
|
+
// (C1 hardening), which 401s for a brand-new identity that has no
|
|
264
|
+
// bearer yet. `accessToken`/`refreshToken` are optional on
|
|
265
|
+
// SessionLoginResponse; only plant when an access token is present and
|
|
266
|
+
// default the refresh token to an empty string.
|
|
267
|
+
if (res?.accessToken) {
|
|
268
|
+
this.setTokens(res.accessToken, res.refreshToken ?? '');
|
|
269
|
+
}
|
|
270
|
+
return res;
|
|
258
271
|
}
|
|
259
272
|
catch (error) {
|
|
260
273
|
throw this.handleError(error);
|