@ar-agents/mercadopago 0.18.6 → 0.18.7

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/index.js CHANGED
@@ -1942,7 +1942,17 @@ async function parseTokenResponse(res) {
1942
1942
  `MP OAuth ${res.status}: ${text.slice(0, 300)}`
1943
1943
  );
1944
1944
  }
1945
- const json = JSON.parse(text);
1945
+ let json;
1946
+ try {
1947
+ json = JSON.parse(text);
1948
+ } catch {
1949
+ throw new MercadoPagoError(
1950
+ `MP OAuth ${res.status}: token response is not valid JSON: ${text.slice(0, 300)}`,
1951
+ res.status,
1952
+ "/oauth/token",
1953
+ text.slice(0, 300)
1954
+ );
1955
+ }
1946
1956
  return OAuthTokenSchema.parse(json);
1947
1957
  }
1948
1958
  function expirationTimeMs(issuedAtMs, expiresInSeconds) {