60p82u21t54k 1.1.2 → 1.1.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.
@@ -10300,9 +10300,21 @@ registerAllApiModels();
10300
10300
  const get = (endpoint) => __async(void 0, null, function* () {
10301
10301
  const response = yield fetchWithTimeout(`${endpoint}`, {
10302
10302
  method: "GET",
10303
- headers: authHeaders()
10303
+ headers: authHeaders(),
10304
+ credentials: "include"
10304
10305
  });
10305
- return handleGetResponse(response);
10306
+ if (!response.ok) {
10307
+ const errorResponse = yield getErrorMessage(response);
10308
+ return Promise.reject(errorResponse);
10309
+ }
10310
+ const data = yield safeJson(response);
10311
+ return {
10312
+ data,
10313
+ status: response.status,
10314
+ msg: response.statusText,
10315
+ headers: response.headers,
10316
+ ok: response.ok
10317
+ };
10306
10318
  });
10307
10319
  const post = (requests, requestPath = `/graph/jwt`) => __async(void 0, null, function* () {
10308
10320
  const modifiedRequests = processRequestModifications(requests);
@@ -10314,17 +10326,58 @@ const post = (requests, requestPath = `/graph/jwt`) => __async(void 0, null, fun
10314
10326
  const response = yield fetchWithTimeout(requestPath, {
10315
10327
  method: "POST",
10316
10328
  headers: authHeaders(),
10317
- body: JSON.stringify(payload)
10329
+ body: JSON.stringify(payload),
10330
+ credentials: "include"
10318
10331
  });
10319
- return handlePostResponse(response);
10332
+ if (!response.ok) {
10333
+ const errorResponse = yield getErrorMessage(response);
10334
+ return Promise.reject(errorResponse);
10335
+ }
10336
+ const responseJSON = yield safeJson(response);
10337
+ const result = {
10338
+ status: 200,
10339
+ message: "",
10340
+ result: {}
10341
+ };
10342
+ for (const res of responseJSON.responses) {
10343
+ if (res.error != null && res.error.code != 200) {
10344
+ result.status = res.error.code;
10345
+ result.message = res.error.message;
10346
+ }
10347
+ const decodedData = res.attributes !== null && res.attributes !== void 0 ? base64Decode(res.attributes) : null;
10348
+ const name = res.name;
10349
+ const responseData = decodedData ? JSON.parse(decodedData) : null;
10350
+ if (!responseData) {
10351
+ result.result[name] = null;
10352
+ } else {
10353
+ result.result[name] = processApiTransformation(
10354
+ name,
10355
+ responseData
10356
+ );
10357
+ }
10358
+ }
10359
+ result.result = processResponseModifications(result.result);
10360
+ return result;
10320
10361
  });
10321
10362
  const customPost = (requestPath, request) => __async(void 0, null, function* () {
10322
10363
  const response = yield fetchWithTimeout(requestPath, {
10323
10364
  method: "POST",
10324
10365
  headers: authHeaders(),
10325
- body: JSON.stringify(request)
10366
+ body: JSON.stringify(request),
10367
+ credentials: "include"
10326
10368
  });
10327
- return handleCustomPostResponse(response);
10369
+ if (!response.ok) {
10370
+ const errorResponse = yield getErrorMessage(response);
10371
+ return Promise.reject(errorResponse);
10372
+ }
10373
+ const data = yield safeJson(response);
10374
+ const responses = Array.isArray(data == null ? void 0 : data.responses) ? data.responses.filter((res) => res == null ? void 0 : res.attributes) : [];
10375
+ if (responses.length === 0) {
10376
+ return true;
10377
+ }
10378
+ const firstResponse = responses[0];
10379
+ const decodedData = base64Decode(firstResponse.attributes);
10380
+ return JSON.parse(decodedData);
10328
10381
  });
10329
10382
  const fetchWithTimeout = (url, options, timeout = 29e3) => __async(void 0, null, function* () {
10330
10383
  const controller = new AbortController();
@@ -10339,10 +10392,15 @@ const fetchWithTimeout = (url, options, timeout = 29e3) => __async(void 0, null,
10339
10392
  }
10340
10393
  });
10341
10394
  const authHeaders = () => {
10342
- const token = localStorage.getItem("token");
10343
- return __spreadValues({
10344
- "Content-Type": "application/json"
10345
- }, token ? { Authorization: `Bearer ${token}` } : {});
10395
+ const csrfToken = getCookie("XSRF-TOKEN");
10396
+ return {
10397
+ "Content-Type": "application/json",
10398
+ "X-XSRF-TOKEN": csrfToken
10399
+ };
10400
+ };
10401
+ const getCookie = (name) => {
10402
+ const match2 = document.cookie.match(new RegExp("(^| )" + name + "=([^;]+)"));
10403
+ return match2 ? decodeURIComponent(match2[2]) : "";
10346
10404
  };
10347
10405
  const safeJson = (response) => __async(void 0, null, function* () {
10348
10406
  try {
@@ -10370,66 +10428,6 @@ const getErrorMessage = (response) => __async(void 0, null, function* () {
10370
10428
  }
10371
10429
  return errorResponse;
10372
10430
  });
10373
- const handleGetResponse = (response) => __async(void 0, null, function* () {
10374
- if (!response.ok) {
10375
- const errorResponse = yield getErrorMessage(response);
10376
- return Promise.reject(errorResponse);
10377
- }
10378
- const data = yield safeJson(response);
10379
- return {
10380
- data,
10381
- status: response.status,
10382
- msg: response.statusText,
10383
- headers: response.headers,
10384
- ok: response.ok
10385
- };
10386
- });
10387
- const handlePostResponse = (response) => __async(void 0, null, function* () {
10388
- const result = {
10389
- status: 200,
10390
- message: "",
10391
- result: {}
10392
- };
10393
- if (!response.ok) {
10394
- const errorResponse = yield getErrorMessage(response);
10395
- return Promise.reject(errorResponse);
10396
- }
10397
- const responseJSON = yield safeJson(response);
10398
- for (const res of responseJSON.responses) {
10399
- if (res.error != null && res.error.code != 200) {
10400
- result.status = res.error.code;
10401
- result.message = res.error.message;
10402
- }
10403
- const decodedData = res.attributes !== null && res.attributes !== void 0 ? base64Decode(res.attributes) : null;
10404
- const name = res.name;
10405
- const responseData = decodedData ? JSON.parse(decodedData) : null;
10406
- if (!responseData) {
10407
- result.result[name] = null;
10408
- } else {
10409
- result.result[name] = processApiTransformation(
10410
- name,
10411
- responseData
10412
- );
10413
- }
10414
- }
10415
- result.result = processResponseModifications(result.result);
10416
- return result;
10417
- });
10418
- const handleCustomPostResponse = (response) => __async(void 0, null, function* () {
10419
- if (!response) return;
10420
- if (!response.ok) {
10421
- const errorResponse = yield getErrorMessage(response);
10422
- return Promise.reject(errorResponse);
10423
- }
10424
- const data = yield safeJson(response);
10425
- const responses = Array.isArray(data == null ? void 0 : data.responses) ? data.responses.filter((res) => res == null ? void 0 : res.attributes) : [];
10426
- if (responses.length === 0) {
10427
- return true;
10428
- }
10429
- const firstResponse = responses[0];
10430
- const decodedData = base64Decode(firstResponse.attributes);
10431
- return JSON.parse(decodedData);
10432
- });
10433
10431
  const api = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
10434
10432
  __proto__: null,
10435
10433
  customPost,