@neetru/sdk 1.1.0 → 1.1.1

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/auth.cjs CHANGED
@@ -70,10 +70,14 @@ async function httpRequest(config, opts) {
70
70
  headers["content-type"] = "application/json";
71
71
  init.body = JSON.stringify(opts.body);
72
72
  }
73
+ init.signal = AbortSignal.timeout(3e4);
73
74
  let res;
74
75
  try {
75
76
  res = await config.fetch(url, init);
76
77
  } catch (err) {
78
+ if (err instanceof DOMException && err.name === "TimeoutError") {
79
+ throw new NeetruError("network_error", "Network error: timeout after 30s");
80
+ }
77
81
  const message = err instanceof Error ? err.message : "fetch failed";
78
82
  throw new NeetruError("network_error", `Network error: ${message}`);
79
83
  }
@@ -1224,7 +1228,9 @@ function createOidcAuthNamespace(config) {
1224
1228
  const redirectUri = options?.redirectUri ?? globalThis.location.origin;
1225
1229
  const scope = options?.scope ?? "openid profile email";
1226
1230
  const state = options?.postLoginRedirect ?? globalThis.location.href;
1227
- const url = new URL("/oauth/authorize", config.baseUrl.replace(/\/api$/, ""));
1231
+ const overrideAuthUrl = typeof globalThis.NEETRU_AUTH_URL === "string" ? globalThis.NEETRU_AUTH_URL : null;
1232
+ const idpOrigin = overrideAuthUrl ?? config.baseUrl.replace(/^https?:\/\/api\./, "https://auth.");
1233
+ const url = new URL("/api/v1/oauth/authorize", idpOrigin);
1228
1234
  url.searchParams.set("response_type", "code");
1229
1235
  url.searchParams.set("redirect_uri", redirectUri);
1230
1236
  url.searchParams.set("scope", scope);