glitchgrab 1.66.2 → 1.67.0
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/server.js +12 -2
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +12 -2
- package/dist/server.mjs.map +1 -1
- package/package.json +1 -1
package/dist/server.mjs
CHANGED
|
@@ -250,6 +250,7 @@ function signSession(options) {
|
|
|
250
250
|
}
|
|
251
251
|
var GUIDES_REVALIDATE_SECONDS = 300;
|
|
252
252
|
var SDK_API_TIMEOUT_MS = 5e3;
|
|
253
|
+
var SDK_LINE_REQUEST_TIMEOUT_MS = 4e4;
|
|
253
254
|
async function callSdkApi(path, token, options, init) {
|
|
254
255
|
var _a, _b, _c, _d, _e, _f;
|
|
255
256
|
const baseUrl = ((_c = (_b = (_a = options.baseUrl) != null ? _a : defaults.baseUrl) != null ? _b : readEnv("GLITCHGRAB_BASE_URL")) != null ? _c : DEFAULT_BASE_URL).replace(/\/+$/, "");
|
|
@@ -277,7 +278,10 @@ async function callSdkApi(path, token, options, init) {
|
|
|
277
278
|
};
|
|
278
279
|
}
|
|
279
280
|
return { data: (_f = body.data) != null ? _f : null, error: null };
|
|
280
|
-
} catch (
|
|
281
|
+
} catch (err) {
|
|
282
|
+
if ((controller == null ? void 0 : controller.signal.aborted) || err instanceof Error && err.name === "AbortError") {
|
|
283
|
+
return { data: null, error: "Glitchgrab took too long", code: "TIMEOUT" };
|
|
284
|
+
}
|
|
281
285
|
return { data: null, error: "Could not reach Glitchgrab" };
|
|
282
286
|
} finally {
|
|
283
287
|
if (timer) clearTimeout(timer);
|
|
@@ -968,10 +972,16 @@ async function getPhoneLine(params = {}, options = {}) {
|
|
|
968
972
|
}
|
|
969
973
|
}
|
|
970
974
|
async function lineRequestCall(path, body, options) {
|
|
975
|
+
var _a;
|
|
971
976
|
try {
|
|
972
977
|
const key = callsKey(options);
|
|
973
978
|
if (!key) return { ok: false, error: NO_KEY_ERROR };
|
|
974
|
-
const { data, error, code } = await callSdkApi(
|
|
979
|
+
const { data, error, code } = await callSdkApi(
|
|
980
|
+
path,
|
|
981
|
+
key,
|
|
982
|
+
{ ...options, timeoutMs: (_a = options.timeoutMs) != null ? _a : SDK_LINE_REQUEST_TIMEOUT_MS },
|
|
983
|
+
{ method: "POST", body, cache: "no-store" }
|
|
984
|
+
);
|
|
975
985
|
const request = isRecord(data) ? lineRequestOf(data.request) : null;
|
|
976
986
|
if (error !== null || !request) return { ok: false, error: error != null ? error : "Unexpected response", ...code ? { code } : {} };
|
|
977
987
|
return { ok: true, request };
|