@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.
@@ -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
- this.config = config;
22
- this.cloudURL = config.cloudURL || 'https://cloud.oxy.so';
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(config);
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