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