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