kaafil-js 0.6.0 → 0.6.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.
package/dist/index.js CHANGED
@@ -1811,7 +1811,8 @@ function parseRetryAfterSeconds(headerValue) {
1811
1811
  return Number.isFinite(seconds) && seconds >= 0 ? seconds : void 0;
1812
1812
  }
1813
1813
  function attachMeta(data, meta, facets) {
1814
- const withMeta = Object.assign(data, { meta });
1814
+ const base = data === void 0 || data === null ? {} : data;
1815
+ const withMeta = Object.assign(base, { meta });
1815
1816
  return facets === void 0 ? withMeta : Object.assign(withMeta, { facets });
1816
1817
  }
1817
1818
  function describeCrossOriginSuspect(url) {
@@ -1875,6 +1876,18 @@ function sendOnce(ctx, request, idempotencyKey) {
1875
1876
  return sendOnceWith(ctx, request, idempotencyKey, async (response, status, requestId) => {
1876
1877
  const text = await response.text();
1877
1878
  const body = text.length > 0 ? tryParseJson(text) : void 0;
1879
+ if (body === void 0 && status >= 200 && status < 300) {
1880
+ const serverDate = response.headers.get("date");
1881
+ return {
1882
+ data: void 0,
1883
+ meta: {
1884
+ status,
1885
+ requestId,
1886
+ ...serverDate === null ? {} : { serverTime: new Date(serverDate).toISOString() }
1887
+ },
1888
+ facets: void 0
1889
+ };
1890
+ }
1878
1891
  if (!isSuccessEnvelope(body)) {
1879
1892
  throw new KaafilNetworkError(`Received an unrecognizable success body for HTTP ${status}`, {
1880
1893
  status,