apps-sdk 2.1.4 → 2.1.5

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/config.js CHANGED
@@ -26,6 +26,7 @@ const config = {
26
26
 
27
27
  WEBAPP_PATHS: {
28
28
  GET_CREDITS: "/user/get-credits",
29
+ CHECK_SUBS: "/user/check-subs",
29
30
  },
30
31
 
31
32
  LEGAL_PATHS: {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "apps-sdk",
3
- "version": "2.1.4",
4
- "description": "Apps SDK - Compatible with Expo SDK 54 + React 19 - add rating flow, auth modules",
3
+ "version": "2.1.5",
4
+ "description": "Apps SDK - Compatible with Expo SDK 54 + React 19 - add generic method checksubscription to check if user has active subscription in webapp",
5
5
  "main": "index.js",
6
6
  "author": "ASD",
7
7
  "license": "ISC",
@@ -284,6 +284,37 @@ class Session {
284
284
  return 0;
285
285
  }
286
286
  }
287
+
288
+ checkSubscriptionWebapp = async (webappUrl, websiteId) => {
289
+ config.DEBUG_MODE && console.debug("checkSubscriptionWebapp");
290
+
291
+ try {
292
+ const endpoint = `${webappUrl}${config.WEBAPP_PATHS.CHECK_SUBS}`;
293
+ const payload = this.getWebappBasePayload(websiteId);
294
+
295
+ const response = await fetch(endpoint, {
296
+ method: 'POST',
297
+ headers: { 'Content-Type': 'application/json' },
298
+ body: JSON.stringify(payload),
299
+ });
300
+
301
+ const data = await response.json();
302
+ config.DEBUG_MODE && console.debug("checkSubscriptionWebapp - result: ", data);
303
+
304
+ if (data?.success && data?.data?.[0]) {
305
+ const subData = data.data[0];
306
+ await this.setIsSubscribed(subData.subscription_active);
307
+ await this.setSubscriptionData(subData);
308
+
309
+ return subData;
310
+ }
311
+
312
+ return null;
313
+ } catch (error) {
314
+ console.error('[SDK] checkSubscriptionWebapp error:', error);
315
+ return null;
316
+ }
317
+ }
287
318
  }
288
319
 
289
320
  export default new Session();
package/types/index.d.ts CHANGED
@@ -40,6 +40,7 @@ declare module 'apps-sdk' {
40
40
  setUserCreateEndpoint(endpoint: string): void;
41
41
  setBaseUrl(baseUrl: string): void;
42
42
  getCredits(webappUrl: string, websiteId: string): Promise<number>;
43
+ checkSubscriptionWebapp(webappUrl: string, websiteId: string): Promise<any>;
43
44
  getWebappBasePayload(websiteId: string, additionalData?: any): any;
44
45
  initSession(): Promise<void>;
45
46
  storeSessionStructure(): Promise<void>;