@iblai/web-utils 1.6.4 → 1.6.6

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.js CHANGED
@@ -442,6 +442,14 @@ const BASE_CONFIG = {
442
442
  description: "Default mentor to open on the platform",
443
443
  type: "string",
444
444
  },
445
+ /* {
446
+ slug: "monetization_base_path",
447
+ label: "Public Monetization Base Path",
448
+ defaultValue: "https://ibl.ai/buy/",
449
+ description:
450
+ "Base URL for public paywall product pages. The product unique ID will be appended to this path.",
451
+ type: "string",
452
+ }, */
445
453
  ],
446
454
  };
447
455
  // SkillsAI platform configuration
@@ -2874,13 +2882,20 @@ async function isDmTokenExpired(storageService) {
2874
2882
  * @returns boolean indicating if token is valid for current user
2875
2883
  */
2876
2884
  async function validateJwtToken(storageService) {
2885
+ let edxJwtToken;
2877
2886
  try {
2878
- const edxJwtToken = await storageService.getItem(LOCAL_STORAGE_KEYS.EDX_TOKEN_KEY);
2887
+ edxJwtToken = await storageService.getItem(LOCAL_STORAGE_KEYS.EDX_TOKEN_KEY);
2879
2888
  console.log("[AuthProvider] JWT token ", edxJwtToken);
2880
2889
  const userData = await storageService.getItem(LOCAL_STORAGE_KEYS.USER_DATA);
2881
2890
  if (!edxJwtToken || !userData) {
2882
2891
  return false;
2883
2892
  }
2893
+ // Skip JWT validation if token is not in JWT format (e.g. opaque LTI tokens)
2894
+ const parts = edxJwtToken.split(".");
2895
+ if (parts.length !== 3) {
2896
+ console.warn("[AuthProvider] Token is not a valid JWT format, skipping validation");
2897
+ return false;
2898
+ }
2884
2899
  const decodedToken = jwtDecode(edxJwtToken);
2885
2900
  const userDataObj = JSON.parse(userData);
2886
2901
  // Compare user_id from token with user_id from user_data
@@ -2892,7 +2907,7 @@ async function validateJwtToken(storageService) {
2892
2907
  return true;
2893
2908
  }
2894
2909
  catch (error) {
2895
- console.error("[AuthProvider] Error validating JWT token:", error);
2910
+ console.error("[AuthProvider] Error validating JWT token:", error, "Token is ", edxJwtToken);
2896
2911
  return false;
2897
2912
  }
2898
2913
  }
@@ -15582,6 +15597,15 @@ createApi({
15582
15597
  }),
15583
15598
  invalidatesTags: ['paywallConfig', 'paywalls'],
15584
15599
  }),
15600
+ updatePaywall: builder.mutation({
15601
+ query: ({ platform_key, item_type, item_id, ...body }) => ({
15602
+ url: MONETIZATION_ENDPOINTS.PAYWALL_CONFIG.path(platform_key, item_type, item_id),
15603
+ service: MONETIZATION_ENDPOINTS.PAYWALL_CONFIG.service,
15604
+ method: 'PUT',
15605
+ body: JSON.stringify(body),
15606
+ }),
15607
+ invalidatesTags: ['paywallConfig', 'paywalls'],
15608
+ }),
15585
15609
  disablePaywall: builder.mutation({
15586
15610
  query: ({ platform_key, item_type, item_id }) => ({
15587
15611
  url: MONETIZATION_ENDPOINTS.PAYWALL_CONFIG.path(platform_key, item_type, item_id),
@@ -15641,6 +15665,9 @@ createApi({
15641
15665
  url: MONETIZATION_ENDPOINTS.ACCESS_CHECK.path(platform_key, item_type, item_id),
15642
15666
  service: MONETIZATION_ENDPOINTS.ACCESS_CHECK.service,
15643
15667
  method: 'GET',
15668
+ // Treat paywall-related 4xx (e.g. 402 Payment Required) as success so the
15669
+ // response body (has_access, pricing, reason, …) reaches the caller as `data`.
15670
+ validateStatus: (response) => response.ok || [402].includes(response.status),
15644
15671
  }),
15645
15672
  providesTags: ['accessCheck'],
15646
15673
  }),