@muze-nl/metro-oidc 0.9.2 → 0.9.3

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/browser.js CHANGED
@@ -3800,23 +3800,23 @@
3800
3800
  //...
3801
3801
  );
3802
3802
  const storeIdToken = async (req2, next2) => {
3803
- const res2 = await next2(req2);
3804
3803
  const tokenEndpoint = url(options.openid_configuration.token_endpoint, { hash: "" }).href;
3805
3804
  const requestUrl = url(req2.url, { hash: "" }).href;
3806
3805
  if (requestUrl !== tokenEndpoint) {
3807
- return res2;
3806
+ return next2(req2);
3808
3807
  }
3808
+ const isRefresh = await grantTypeOf(req2) == "refresh_token";
3809
+ const res2 = await next2(req2);
3809
3810
  const contentType = res2.headers.get("content-type");
3810
3811
  if (!res2.ok || !contentType?.startsWith("application/json")) {
3811
3812
  return res2;
3812
3813
  }
3813
- let data = res2.data && typeof res2.data === "object" ? res2.data : null;
3814
- if (!data) {
3814
+ let data = res2.data;
3815
+ if (!data || typeof data !== "object" || data instanceof ReadableStream) {
3815
3816
  const res22 = res2.clone();
3816
3817
  data = await res22.json();
3817
3818
  }
3818
3819
  const id_token = data?.id_token;
3819
- const isRefresh = await grantTypeOf(req2) == "refresh_token";
3820
3820
  if (isRefresh && !id_token) {
3821
3821
  return res2;
3822
3822
  }