@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
|
@@ -252,7 +252,7 @@ function OxyServicesAuthMixin(Base) {
|
|
|
252
252
|
*/
|
|
253
253
|
async verifyChallenge(publicKey, challenge, signature, timestamp, deviceName, deviceFingerprint) {
|
|
254
254
|
try {
|
|
255
|
-
|
|
255
|
+
const res = await this.makeRequest('POST', '/auth/verify', {
|
|
256
256
|
publicKey,
|
|
257
257
|
challenge,
|
|
258
258
|
signature,
|
|
@@ -260,6 +260,19 @@ function OxyServicesAuthMixin(Base) {
|
|
|
260
260
|
deviceName,
|
|
261
261
|
deviceFingerprint,
|
|
262
262
|
}, { cache: false });
|
|
263
|
+
// Plant the freshly-minted tokens, mirroring `claimSessionByToken`.
|
|
264
|
+
// `/auth/verify` returns the first access token (and refresh token) in
|
|
265
|
+
// its body, so installing it here means callers get an authenticated
|
|
266
|
+
// client without a second round-trip — and, critically, without
|
|
267
|
+
// falling back to the bearer-protected `GET /session/token/:sessionId`
|
|
268
|
+
// (C1 hardening), which 401s for a brand-new identity that has no
|
|
269
|
+
// bearer yet. `accessToken`/`refreshToken` are optional on
|
|
270
|
+
// SessionLoginResponse; only plant when an access token is present and
|
|
271
|
+
// default the refresh token to an empty string.
|
|
272
|
+
if (res?.accessToken) {
|
|
273
|
+
this.setTokens(res.accessToken, res.refreshToken ?? '');
|
|
274
|
+
}
|
|
275
|
+
return res;
|
|
263
276
|
}
|
|
264
277
|
catch (error) {
|
|
265
278
|
throw this.handleError(error);
|