@goralys/core 1.4.0 → 1.4.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.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  interface GoralysClientConfig {
2
2
  apiDomain: string;
3
3
  schoolToken: string;
4
+ isNative: boolean;
4
5
  }
5
6
  declare function configureGoralysClient(cfg: GoralysClientConfig): void;
6
7
  declare function getGoralysClientConfig(): GoralysClientConfig;
package/dist/index.js CHANGED
@@ -414,11 +414,15 @@ var GoralysActionHandler = class {
414
414
  // src/lib/fetch/fetch.client.ts
415
415
  var actionHandler = new GoralysActionHandler();
416
416
  async function goralysFetchClient(method, input, payload, requestOptions) {
417
- const { apiDomain, schoolToken } = getGoralysClientConfig();
417
+ const { apiDomain, schoolToken, isNative } = getGoralysClientConfig();
418
418
  const res = await fetch(`${apiDomain}/${input}`, {
419
419
  credentials: "include",
420
420
  method: method === "BREW" ? "POST" : method,
421
- headers: { ...method === "BREW" ? { "X-HTTP-Method-Override": method } : {}, "X-High-School-Token": schoolToken },
421
+ headers: {
422
+ ...method === "BREW" ? { "X-HTTP-Method-Override": method } : {},
423
+ "X-High-School-Token": schoolToken,
424
+ "X-Goralys-Client": isNative ? "mobile" : "desktop"
425
+ },
422
426
  body: payload ? payload instanceof FormData ? payload : JSON.stringify(payload) : void 0,
423
427
  ...requestOptions
424
428
  });
@@ -427,6 +431,9 @@ async function goralysFetchClient(method, input, payload, requestOptions) {
427
431
  if (!(contentType && contentType.toLowerCase().trim().includes("application/json")))
428
432
  return res;
429
433
  const data = await clone.json();
434
+ if (data?.redirect) {
435
+ emitNavigationEvent({ type: "redirect", url: data.redirect });
436
+ }
430
437
  if (res.status === 401) {
431
438
  try {
432
439
  emitAuthEvent(data?.authEvent ?? "unauthenticated");
@@ -447,10 +454,14 @@ async function goralysFetchClient(method, input, payload, requestOptions) {
447
454
  return res;
448
455
  }
449
456
  async function fetchCsrfClient(formId) {
450
- const { apiDomain, schoolToken } = getGoralysClientConfig();
457
+ const { apiDomain, schoolToken, isNative } = getGoralysClientConfig();
451
458
  const res = await fetch(`${apiDomain}/csrf`, {
452
459
  method: "POST",
453
- headers: { "Content-Type": "application/json", "X-High-School-Token": schoolToken },
460
+ headers: {
461
+ "Content-Type": "application/json",
462
+ "X-High-School-Token": schoolToken,
463
+ "X-Goralys-Client": isNative ? "mobile" : "desktop"
464
+ },
454
465
  credentials: "include",
455
466
  body: JSON.stringify({ form: formId })
456
467
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goralys/core",
3
- "version": "1.4.0",
3
+ "version": "1.4.2",
4
4
  "license": "LGPL-2.1-or-later",
5
5
  "description": "Shared business logic for the Goralys web application",
6
6
  "repository": {