@proveanything/smartlinks 1.9.6 → 1.9.8
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/docs/API_SUMMARY.md +1 -1
- package/dist/http.js +10 -5
- package/docs/API_SUMMARY.md +1 -1
- package/package.json +1 -1
package/dist/docs/API_SUMMARY.md
CHANGED
package/dist/http.js
CHANGED
|
@@ -680,7 +680,7 @@ function ensureProxyListener() {
|
|
|
680
680
|
if (window._smartlinksProxyListener)
|
|
681
681
|
return;
|
|
682
682
|
window.addEventListener("message", (event) => {
|
|
683
|
-
var _a;
|
|
683
|
+
var _a, _b, _c, _d;
|
|
684
684
|
const msg = event.data;
|
|
685
685
|
if ((msg === null || msg === void 0 ? void 0 : msg._smartlinksProxyStream) && msg.id) {
|
|
686
686
|
const pendingStream = proxyStreamPending.get(msg.id);
|
|
@@ -706,12 +706,17 @@ function ensureProxyListener() {
|
|
|
706
706
|
const pending = proxyPending[msg.id];
|
|
707
707
|
if (pending) {
|
|
708
708
|
if (msg.error) {
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
709
|
+
// msg.error may be a string or an object (e.g. { message, statusCode, errorCode, ... })
|
|
710
|
+
const errObj = typeof msg.error === 'object' && msg.error !== null ? msg.error : null;
|
|
711
|
+
const statusCode = (_a = msg.statusCode) !== null && _a !== void 0 ? _a : errObj === null || errObj === void 0 ? void 0 : errObj.statusCode;
|
|
712
|
+
const message = (_b = errObj === null || errObj === void 0 ? void 0 : errObj.message) !== null && _b !== void 0 ? _b : (typeof msg.error === 'string' ? msg.error : 'Request failed');
|
|
713
|
+
const errorBody = (_d = (_c = msg.errorBody) !== null && _c !== void 0 ? _c : errObj) !== null && _d !== void 0 ? _d : msg.error;
|
|
714
|
+
if (statusCode) {
|
|
715
|
+
const errBody = normalizeErrorResponse(errorBody, statusCode);
|
|
716
|
+
pending.reject(new SmartlinksApiError(message, statusCode, errBody));
|
|
712
717
|
}
|
|
713
718
|
else {
|
|
714
|
-
pending.reject(new Error(
|
|
719
|
+
pending.reject(new Error(message));
|
|
715
720
|
}
|
|
716
721
|
}
|
|
717
722
|
else {
|
package/docs/API_SUMMARY.md
CHANGED