@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/data-layer/src/features/monetization/custom-api-slice.d.ts +161 -0
- package/dist/data-layer/src/features/monetization/types.d.ts +4 -0
- package/dist/index.esm.js +29 -2
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +29 -2
- package/dist/index.js.map +1 -1
- package/dist/package.json +1 -1
- package/package.json +1 -1
|
@@ -9,6 +9,7 @@ export declare const monetizationApiSlice: import("@reduxjs/toolkit/query").Api<
|
|
|
9
9
|
}, import("@reduxjs/toolkit/query").BaseQueryFn<import("../utils").CustomQueryArgs, unknown, import("../utils").ExtendedFetchBaseQueryError, Record<string, unknown>, import("@reduxjs/toolkit/query").FetchBaseQueryMeta>, "stripeConnectStatus" | "paywallConfig" | "paywallPrices" | "publicPricing" | "accessCheck" | "mySubscriptions" | "itemSubscription" | "paywalls" | "subscribers" | "revenue", StripeConnectDashboardResponse, "monetizationApiSlice", unknown>;
|
|
10
10
|
getPaywallConfig: import("@reduxjs/toolkit/query").QueryDefinition<PaywallItemParams, import("@reduxjs/toolkit/query").BaseQueryFn<import("../utils").CustomQueryArgs, unknown, import("../utils").ExtendedFetchBaseQueryError, Record<string, unknown>, import("@reduxjs/toolkit/query").FetchBaseQueryMeta>, "stripeConnectStatus" | "paywallConfig" | "paywallPrices" | "publicPricing" | "accessCheck" | "mySubscriptions" | "itemSubscription" | "paywalls" | "subscribers" | "revenue", PaywallConfigResponse, "monetizationApiSlice", unknown>;
|
|
11
11
|
enablePaywall: import("@reduxjs/toolkit/query").MutationDefinition<EnablePaywallArgs, import("@reduxjs/toolkit/query").BaseQueryFn<import("../utils").CustomQueryArgs, unknown, import("../utils").ExtendedFetchBaseQueryError, Record<string, unknown>, import("@reduxjs/toolkit/query").FetchBaseQueryMeta>, "stripeConnectStatus" | "paywallConfig" | "paywallPrices" | "publicPricing" | "accessCheck" | "mySubscriptions" | "itemSubscription" | "paywalls" | "subscribers" | "revenue", PaywallConfigResponse, "monetizationApiSlice", unknown>;
|
|
12
|
+
updatePaywall: import("@reduxjs/toolkit/query").MutationDefinition<EnablePaywallArgs, import("@reduxjs/toolkit/query").BaseQueryFn<import("../utils").CustomQueryArgs, unknown, import("../utils").ExtendedFetchBaseQueryError, Record<string, unknown>, import("@reduxjs/toolkit/query").FetchBaseQueryMeta>, "stripeConnectStatus" | "paywallConfig" | "paywallPrices" | "publicPricing" | "accessCheck" | "mySubscriptions" | "itemSubscription" | "paywalls" | "subscribers" | "revenue", PaywallConfigResponse, "monetizationApiSlice", unknown>;
|
|
12
13
|
disablePaywall: import("@reduxjs/toolkit/query").MutationDefinition<PaywallItemParams, import("@reduxjs/toolkit/query").BaseQueryFn<import("../utils").CustomQueryArgs, unknown, import("../utils").ExtendedFetchBaseQueryError, Record<string, unknown>, import("@reduxjs/toolkit/query").FetchBaseQueryMeta>, "stripeConnectStatus" | "paywallConfig" | "paywallPrices" | "publicPricing" | "accessCheck" | "mySubscriptions" | "itemSubscription" | "paywalls" | "subscribers" | "revenue", void, "monetizationApiSlice", unknown>;
|
|
13
14
|
listPrices: import("@reduxjs/toolkit/query").QueryDefinition<PaywallItemParams, import("@reduxjs/toolkit/query").BaseQueryFn<import("../utils").CustomQueryArgs, unknown, import("../utils").ExtendedFetchBaseQueryError, Record<string, unknown>, import("@reduxjs/toolkit/query").FetchBaseQueryMeta>, "stripeConnectStatus" | "paywallConfig" | "paywallPrices" | "publicPricing" | "accessCheck" | "mySubscriptions" | "itemSubscription" | "paywalls" | "subscribers" | "revenue", PaywallPrice[], "monetizationApiSlice", unknown>;
|
|
14
15
|
createPrice: import("@reduxjs/toolkit/query").MutationDefinition<CreatePriceArgs, import("@reduxjs/toolkit/query").BaseQueryFn<import("../utils").CustomQueryArgs, unknown, import("../utils").ExtendedFetchBaseQueryError, Record<string, unknown>, import("@reduxjs/toolkit/query").FetchBaseQueryMeta>, "stripeConnectStatus" | "paywallConfig" | "paywallPrices" | "publicPricing" | "accessCheck" | "mySubscriptions" | "itemSubscription" | "paywalls" | "subscribers" | "revenue", PaywallPrice, "monetizationApiSlice", unknown>;
|
|
@@ -1222,6 +1223,166 @@ export declare const useGetStripeConnectStatusQuery: <R extends Record<string, a
|
|
|
1222
1223
|
} | undefined) => readonly [(arg: EnablePaywallArgs) => import("@reduxjs/toolkit/query").MutationActionCreatorResult<import("@reduxjs/toolkit/query").MutationDefinition<EnablePaywallArgs, import("@reduxjs/toolkit/query").BaseQueryFn<import("../utils").CustomQueryArgs, unknown, import("../utils").ExtendedFetchBaseQueryError, Record<string, unknown>, import("@reduxjs/toolkit/query").FetchBaseQueryMeta>, "stripeConnectStatus" | "paywallConfig" | "paywallPrices" | "publicPricing" | "accessCheck" | "mySubscriptions" | "itemSubscription" | "paywalls" | "subscribers" | "revenue", PaywallConfigResponse, "monetizationApiSlice", unknown>>, import("@reduxjs/toolkit/query").TSHelpersNoInfer<R> & {
|
|
1223
1224
|
originalArgs?: EnablePaywallArgs | undefined;
|
|
1224
1225
|
reset: () => void;
|
|
1226
|
+
}], useUpdatePaywallMutation: <R extends Record<string, any> = ({
|
|
1227
|
+
requestId?: undefined;
|
|
1228
|
+
status: import("@reduxjs/toolkit/query").QueryStatus.uninitialized;
|
|
1229
|
+
data?: undefined;
|
|
1230
|
+
error?: undefined;
|
|
1231
|
+
endpointName?: string;
|
|
1232
|
+
startedTimeStamp?: undefined;
|
|
1233
|
+
fulfilledTimeStamp?: undefined;
|
|
1234
|
+
} & {
|
|
1235
|
+
status: import("@reduxjs/toolkit/query").QueryStatus.uninitialized;
|
|
1236
|
+
isUninitialized: true;
|
|
1237
|
+
isLoading: false;
|
|
1238
|
+
isSuccess: false;
|
|
1239
|
+
isError: false;
|
|
1240
|
+
}) | ({
|
|
1241
|
+
status: import("@reduxjs/toolkit/query").QueryStatus.fulfilled;
|
|
1242
|
+
} & Omit<{
|
|
1243
|
+
requestId: string;
|
|
1244
|
+
data?: PaywallConfigResponse | undefined;
|
|
1245
|
+
error?: import("../utils").ExtendedFetchBaseQueryError | import("@reduxjs/toolkit").SerializedError | undefined;
|
|
1246
|
+
endpointName: string;
|
|
1247
|
+
startedTimeStamp: number;
|
|
1248
|
+
fulfilledTimeStamp?: number;
|
|
1249
|
+
}, "data" | "fulfilledTimeStamp"> & Required<Pick<{
|
|
1250
|
+
requestId: string;
|
|
1251
|
+
data?: PaywallConfigResponse | undefined;
|
|
1252
|
+
error?: import("../utils").ExtendedFetchBaseQueryError | import("@reduxjs/toolkit").SerializedError | undefined;
|
|
1253
|
+
endpointName: string;
|
|
1254
|
+
startedTimeStamp: number;
|
|
1255
|
+
fulfilledTimeStamp?: number;
|
|
1256
|
+
}, "data" | "fulfilledTimeStamp">> & {
|
|
1257
|
+
error: undefined;
|
|
1258
|
+
} & {
|
|
1259
|
+
status: import("@reduxjs/toolkit/query").QueryStatus.fulfilled;
|
|
1260
|
+
isUninitialized: false;
|
|
1261
|
+
isLoading: false;
|
|
1262
|
+
isSuccess: true;
|
|
1263
|
+
isError: false;
|
|
1264
|
+
}) | ({
|
|
1265
|
+
status: import("@reduxjs/toolkit/query").QueryStatus.pending;
|
|
1266
|
+
} & {
|
|
1267
|
+
requestId: string;
|
|
1268
|
+
data?: PaywallConfigResponse | undefined;
|
|
1269
|
+
error?: import("../utils").ExtendedFetchBaseQueryError | import("@reduxjs/toolkit").SerializedError | undefined;
|
|
1270
|
+
endpointName: string;
|
|
1271
|
+
startedTimeStamp: number;
|
|
1272
|
+
fulfilledTimeStamp?: number;
|
|
1273
|
+
} & {
|
|
1274
|
+
data?: undefined;
|
|
1275
|
+
} & {
|
|
1276
|
+
status: import("@reduxjs/toolkit/query").QueryStatus.pending;
|
|
1277
|
+
isUninitialized: false;
|
|
1278
|
+
isLoading: true;
|
|
1279
|
+
isSuccess: false;
|
|
1280
|
+
isError: false;
|
|
1281
|
+
}) | ({
|
|
1282
|
+
status: import("@reduxjs/toolkit/query").QueryStatus.rejected;
|
|
1283
|
+
} & Omit<{
|
|
1284
|
+
requestId: string;
|
|
1285
|
+
data?: PaywallConfigResponse | undefined;
|
|
1286
|
+
error?: import("../utils").ExtendedFetchBaseQueryError | import("@reduxjs/toolkit").SerializedError | undefined;
|
|
1287
|
+
endpointName: string;
|
|
1288
|
+
startedTimeStamp: number;
|
|
1289
|
+
fulfilledTimeStamp?: number;
|
|
1290
|
+
}, "error"> & Required<Pick<{
|
|
1291
|
+
requestId: string;
|
|
1292
|
+
data?: PaywallConfigResponse | undefined;
|
|
1293
|
+
error?: import("../utils").ExtendedFetchBaseQueryError | import("@reduxjs/toolkit").SerializedError | undefined;
|
|
1294
|
+
endpointName: string;
|
|
1295
|
+
startedTimeStamp: number;
|
|
1296
|
+
fulfilledTimeStamp?: number;
|
|
1297
|
+
}, "error">> & {
|
|
1298
|
+
status: import("@reduxjs/toolkit/query").QueryStatus.rejected;
|
|
1299
|
+
isUninitialized: false;
|
|
1300
|
+
isLoading: false;
|
|
1301
|
+
isSuccess: false;
|
|
1302
|
+
isError: true;
|
|
1303
|
+
})>(options?: {
|
|
1304
|
+
selectFromResult?: ((state: ({
|
|
1305
|
+
requestId?: undefined;
|
|
1306
|
+
status: import("@reduxjs/toolkit/query").QueryStatus.uninitialized;
|
|
1307
|
+
data?: undefined;
|
|
1308
|
+
error?: undefined;
|
|
1309
|
+
endpointName?: string;
|
|
1310
|
+
startedTimeStamp?: undefined;
|
|
1311
|
+
fulfilledTimeStamp?: undefined;
|
|
1312
|
+
} & {
|
|
1313
|
+
status: import("@reduxjs/toolkit/query").QueryStatus.uninitialized;
|
|
1314
|
+
isUninitialized: true;
|
|
1315
|
+
isLoading: false;
|
|
1316
|
+
isSuccess: false;
|
|
1317
|
+
isError: false;
|
|
1318
|
+
}) | ({
|
|
1319
|
+
status: import("@reduxjs/toolkit/query").QueryStatus.fulfilled;
|
|
1320
|
+
} & Omit<{
|
|
1321
|
+
requestId: string;
|
|
1322
|
+
data?: PaywallConfigResponse | undefined;
|
|
1323
|
+
error?: import("../utils").ExtendedFetchBaseQueryError | import("@reduxjs/toolkit").SerializedError | undefined;
|
|
1324
|
+
endpointName: string;
|
|
1325
|
+
startedTimeStamp: number;
|
|
1326
|
+
fulfilledTimeStamp?: number;
|
|
1327
|
+
}, "data" | "fulfilledTimeStamp"> & Required<Pick<{
|
|
1328
|
+
requestId: string;
|
|
1329
|
+
data?: PaywallConfigResponse | undefined;
|
|
1330
|
+
error?: import("../utils").ExtendedFetchBaseQueryError | import("@reduxjs/toolkit").SerializedError | undefined;
|
|
1331
|
+
endpointName: string;
|
|
1332
|
+
startedTimeStamp: number;
|
|
1333
|
+
fulfilledTimeStamp?: number;
|
|
1334
|
+
}, "data" | "fulfilledTimeStamp">> & {
|
|
1335
|
+
error: undefined;
|
|
1336
|
+
} & {
|
|
1337
|
+
status: import("@reduxjs/toolkit/query").QueryStatus.fulfilled;
|
|
1338
|
+
isUninitialized: false;
|
|
1339
|
+
isLoading: false;
|
|
1340
|
+
isSuccess: true;
|
|
1341
|
+
isError: false;
|
|
1342
|
+
}) | ({
|
|
1343
|
+
status: import("@reduxjs/toolkit/query").QueryStatus.pending;
|
|
1344
|
+
} & {
|
|
1345
|
+
requestId: string;
|
|
1346
|
+
data?: PaywallConfigResponse | undefined;
|
|
1347
|
+
error?: import("../utils").ExtendedFetchBaseQueryError | import("@reduxjs/toolkit").SerializedError | undefined;
|
|
1348
|
+
endpointName: string;
|
|
1349
|
+
startedTimeStamp: number;
|
|
1350
|
+
fulfilledTimeStamp?: number;
|
|
1351
|
+
} & {
|
|
1352
|
+
data?: undefined;
|
|
1353
|
+
} & {
|
|
1354
|
+
status: import("@reduxjs/toolkit/query").QueryStatus.pending;
|
|
1355
|
+
isUninitialized: false;
|
|
1356
|
+
isLoading: true;
|
|
1357
|
+
isSuccess: false;
|
|
1358
|
+
isError: false;
|
|
1359
|
+
}) | ({
|
|
1360
|
+
status: import("@reduxjs/toolkit/query").QueryStatus.rejected;
|
|
1361
|
+
} & Omit<{
|
|
1362
|
+
requestId: string;
|
|
1363
|
+
data?: PaywallConfigResponse | undefined;
|
|
1364
|
+
error?: import("../utils").ExtendedFetchBaseQueryError | import("@reduxjs/toolkit").SerializedError | undefined;
|
|
1365
|
+
endpointName: string;
|
|
1366
|
+
startedTimeStamp: number;
|
|
1367
|
+
fulfilledTimeStamp?: number;
|
|
1368
|
+
}, "error"> & Required<Pick<{
|
|
1369
|
+
requestId: string;
|
|
1370
|
+
data?: PaywallConfigResponse | undefined;
|
|
1371
|
+
error?: import("../utils").ExtendedFetchBaseQueryError | import("@reduxjs/toolkit").SerializedError | undefined;
|
|
1372
|
+
endpointName: string;
|
|
1373
|
+
startedTimeStamp: number;
|
|
1374
|
+
fulfilledTimeStamp?: number;
|
|
1375
|
+
}, "error">> & {
|
|
1376
|
+
status: import("@reduxjs/toolkit/query").QueryStatus.rejected;
|
|
1377
|
+
isUninitialized: false;
|
|
1378
|
+
isLoading: false;
|
|
1379
|
+
isSuccess: false;
|
|
1380
|
+
isError: true;
|
|
1381
|
+
})) => R) | undefined;
|
|
1382
|
+
fixedCacheKey?: string;
|
|
1383
|
+
} | undefined) => readonly [(arg: EnablePaywallArgs) => import("@reduxjs/toolkit/query").MutationActionCreatorResult<import("@reduxjs/toolkit/query").MutationDefinition<EnablePaywallArgs, import("@reduxjs/toolkit/query").BaseQueryFn<import("../utils").CustomQueryArgs, unknown, import("../utils").ExtendedFetchBaseQueryError, Record<string, unknown>, import("@reduxjs/toolkit/query").FetchBaseQueryMeta>, "stripeConnectStatus" | "paywallConfig" | "paywallPrices" | "publicPricing" | "accessCheck" | "mySubscriptions" | "itemSubscription" | "paywalls" | "subscribers" | "revenue", PaywallConfigResponse, "monetizationApiSlice", unknown>>, import("@reduxjs/toolkit/query").TSHelpersNoInfer<R> & {
|
|
1384
|
+
originalArgs?: EnablePaywallArgs | undefined;
|
|
1385
|
+
reset: () => void;
|
|
1225
1386
|
}], useDisablePaywallMutation: <R extends Record<string, any> = ({
|
|
1226
1387
|
requestId?: undefined;
|
|
1227
1388
|
status: import("@reduxjs/toolkit/query").QueryStatus.uninitialized;
|
|
@@ -36,6 +36,7 @@ export interface PaywallPrice {
|
|
|
36
36
|
stripe_price_id: string;
|
|
37
37
|
}
|
|
38
38
|
export interface PaywallConfigResponse {
|
|
39
|
+
unique_id: string;
|
|
39
40
|
item_type: string;
|
|
40
41
|
item_id: string;
|
|
41
42
|
item_name: string;
|
|
@@ -57,6 +58,9 @@ export interface EnablePaywallArgs extends PaywallItemParams {
|
|
|
57
58
|
allow_free_tier: boolean;
|
|
58
59
|
trial_period_days: number;
|
|
59
60
|
grandfathering_strategy: 'free_forever' | 'require_subscription';
|
|
61
|
+
item_name?: string;
|
|
62
|
+
description?: string;
|
|
63
|
+
on_successful_payment?: string;
|
|
60
64
|
}
|
|
61
65
|
export interface CreatePriceArgs extends PaywallItemParams {
|
|
62
66
|
name: string;
|
package/dist/index.esm.js
CHANGED
|
@@ -422,6 +422,14 @@ const BASE_CONFIG = {
|
|
|
422
422
|
description: "Default mentor to open on the platform",
|
|
423
423
|
type: "string",
|
|
424
424
|
},
|
|
425
|
+
/* {
|
|
426
|
+
slug: "monetization_base_path",
|
|
427
|
+
label: "Public Monetization Base Path",
|
|
428
|
+
defaultValue: "https://ibl.ai/buy/",
|
|
429
|
+
description:
|
|
430
|
+
"Base URL for public paywall product pages. The product unique ID will be appended to this path.",
|
|
431
|
+
type: "string",
|
|
432
|
+
}, */
|
|
425
433
|
],
|
|
426
434
|
};
|
|
427
435
|
// SkillsAI platform configuration
|
|
@@ -2854,13 +2862,20 @@ async function isDmTokenExpired(storageService) {
|
|
|
2854
2862
|
* @returns boolean indicating if token is valid for current user
|
|
2855
2863
|
*/
|
|
2856
2864
|
async function validateJwtToken(storageService) {
|
|
2865
|
+
let edxJwtToken;
|
|
2857
2866
|
try {
|
|
2858
|
-
|
|
2867
|
+
edxJwtToken = await storageService.getItem(LOCAL_STORAGE_KEYS.EDX_TOKEN_KEY);
|
|
2859
2868
|
console.log("[AuthProvider] JWT token ", edxJwtToken);
|
|
2860
2869
|
const userData = await storageService.getItem(LOCAL_STORAGE_KEYS.USER_DATA);
|
|
2861
2870
|
if (!edxJwtToken || !userData) {
|
|
2862
2871
|
return false;
|
|
2863
2872
|
}
|
|
2873
|
+
// Skip JWT validation if token is not in JWT format (e.g. opaque LTI tokens)
|
|
2874
|
+
const parts = edxJwtToken.split(".");
|
|
2875
|
+
if (parts.length !== 3) {
|
|
2876
|
+
console.warn("[AuthProvider] Token is not a valid JWT format, skipping validation");
|
|
2877
|
+
return false;
|
|
2878
|
+
}
|
|
2864
2879
|
const decodedToken = jwtDecode(edxJwtToken);
|
|
2865
2880
|
const userDataObj = JSON.parse(userData);
|
|
2866
2881
|
// Compare user_id from token with user_id from user_data
|
|
@@ -2872,7 +2887,7 @@ async function validateJwtToken(storageService) {
|
|
|
2872
2887
|
return true;
|
|
2873
2888
|
}
|
|
2874
2889
|
catch (error) {
|
|
2875
|
-
console.error("[AuthProvider] Error validating JWT token:", error);
|
|
2890
|
+
console.error("[AuthProvider] Error validating JWT token:", error, "Token is ", edxJwtToken);
|
|
2876
2891
|
return false;
|
|
2877
2892
|
}
|
|
2878
2893
|
}
|
|
@@ -15562,6 +15577,15 @@ createApi({
|
|
|
15562
15577
|
}),
|
|
15563
15578
|
invalidatesTags: ['paywallConfig', 'paywalls'],
|
|
15564
15579
|
}),
|
|
15580
|
+
updatePaywall: builder.mutation({
|
|
15581
|
+
query: ({ platform_key, item_type, item_id, ...body }) => ({
|
|
15582
|
+
url: MONETIZATION_ENDPOINTS.PAYWALL_CONFIG.path(platform_key, item_type, item_id),
|
|
15583
|
+
service: MONETIZATION_ENDPOINTS.PAYWALL_CONFIG.service,
|
|
15584
|
+
method: 'PUT',
|
|
15585
|
+
body: JSON.stringify(body),
|
|
15586
|
+
}),
|
|
15587
|
+
invalidatesTags: ['paywallConfig', 'paywalls'],
|
|
15588
|
+
}),
|
|
15565
15589
|
disablePaywall: builder.mutation({
|
|
15566
15590
|
query: ({ platform_key, item_type, item_id }) => ({
|
|
15567
15591
|
url: MONETIZATION_ENDPOINTS.PAYWALL_CONFIG.path(platform_key, item_type, item_id),
|
|
@@ -15621,6 +15645,9 @@ createApi({
|
|
|
15621
15645
|
url: MONETIZATION_ENDPOINTS.ACCESS_CHECK.path(platform_key, item_type, item_id),
|
|
15622
15646
|
service: MONETIZATION_ENDPOINTS.ACCESS_CHECK.service,
|
|
15623
15647
|
method: 'GET',
|
|
15648
|
+
// Treat paywall-related 4xx (e.g. 402 Payment Required) as success so the
|
|
15649
|
+
// response body (has_access, pricing, reason, …) reaches the caller as `data`.
|
|
15650
|
+
validateStatus: (response) => response.ok || [402].includes(response.status),
|
|
15624
15651
|
}),
|
|
15625
15652
|
providesTags: ['accessCheck'],
|
|
15626
15653
|
}),
|