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