@oxyhq/core 2.1.1 → 2.1.2
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/dist/cjs/.tsbuildinfo +1 -1
- package/dist/cjs/OxyServices.base.js +16 -3
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/OxyServices.base.js +16 -3
- package/dist/types/.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/OxyServices.base.ts +18 -3
- package/src/mixins/__tests__/constructorAuthWebUrl.test.ts +108 -0
|
@@ -7,6 +7,7 @@ import { jwtDecode } from 'jwt-decode';
|
|
|
7
7
|
import { handleHttpError } from './utils/errorUtils.js';
|
|
8
8
|
import { HttpService } from './HttpService.js';
|
|
9
9
|
import { OxyAuthenticationError, OxyAuthenticationTimeoutError } from './OxyServices.errors.js';
|
|
10
|
+
import { autoDetectAuthWebUrl } from './utils/fapiAutoDetect.js';
|
|
10
11
|
/**
|
|
11
12
|
* Base class for OxyServices with core infrastructure
|
|
12
13
|
*/
|
|
@@ -18,10 +19,22 @@ export class OxyServicesBase {
|
|
|
18
19
|
if (!config || typeof config !== 'object') {
|
|
19
20
|
throw new Error('OxyConfig is required');
|
|
20
21
|
}
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
// Auto-detect the first-party IdP (`auth.<rp-apex>`) when the caller did not
|
|
23
|
+
// pin `authWebUrl` explicitly. This mirrors the provider-`baseURL` path in
|
|
24
|
+
// `@oxyhq/services` (OxyContext), so apps that construct their OWN
|
|
25
|
+
// `OxyServices` instance and pass it to `<OxyProvider oxyServices={...} />`
|
|
26
|
+
// get the same same-site IdP resolution. On web at `https://mention.earth`
|
|
27
|
+
// this yields `https://auth.mention.earth`; on native/SSR (no `window`)
|
|
28
|
+
// `autoDetectAuthWebUrl()` returns `undefined`, leaving the auth mixins'
|
|
29
|
+
// `DEFAULT_AUTH_URL` fallback in effect — native behavior is unchanged.
|
|
30
|
+
// An explicit `authWebUrl` always wins (we only fill it when absent).
|
|
31
|
+
const resolvedConfig = config.authWebUrl
|
|
32
|
+
? config
|
|
33
|
+
: { ...config, authWebUrl: autoDetectAuthWebUrl() };
|
|
34
|
+
this.config = resolvedConfig;
|
|
35
|
+
this.cloudURL = resolvedConfig.cloudURL || 'https://cloud.oxy.so';
|
|
23
36
|
// Initialize unified HTTP service (handles auth, caching, deduplication, queuing, retry)
|
|
24
|
-
this.httpService = new HttpService(
|
|
37
|
+
this.httpService = new HttpService(resolvedConfig);
|
|
25
38
|
}
|
|
26
39
|
// Test-only utility to reset tokens on this instance between jest tests
|
|
27
40
|
// Note: tokens are now per-instance, so create new instances in tests for isolation
|