@sudobility/subscription_service 1.0.12 → 1.0.13

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.
@@ -5,13 +5,13 @@
5
5
  * to fetch user entitlements and subscription information. Handles sandbox
6
6
  * filtering via the `testMode` parameter.
7
7
  */
8
- import type { RevenueCatApiKeys, SubscriptionInfo } from "../types/subscription";
8
+ import type { SubscriptionInfo } from "../types/subscription";
9
9
  /**
10
10
  * Configuration for SubscriptionHelper.
11
11
  */
12
12
  export interface SubscriptionHelperConfig {
13
- /** RevenueCat secret API keys per platform */
14
- revenueCatApiKeys: RevenueCatApiKeys;
13
+ /** RevenueCat secret API key (for server-side use) */
14
+ revenueCatApiKey: string;
15
15
  /** Base URL for RevenueCat API. Defaults to https://api.revenuecat.com/v1 */
16
16
  baseUrl?: string;
17
17
  /** Request timeout in milliseconds. Defaults to 10000 (10 seconds). */
@@ -23,16 +23,16 @@ export interface SubscriptionHelperConfig {
23
23
  *
24
24
  * Uses the RevenueCat REST API v1 endpoint `GET /subscribers/{user_id}` to
25
25
  * fetch subscriber data, then filters entitlements by expiration and sandbox status.
26
- * Queries each configured platform API key and merges the results.
26
+ * Detects the subscription platform from the store field in the response.
27
27
  */
28
28
  export declare class SubscriptionHelper {
29
- private readonly apiKeys;
29
+ private readonly apiKey;
30
30
  private readonly baseUrl;
31
31
  private readonly timeoutMs;
32
32
  /**
33
33
  * Creates a new SubscriptionHelper instance.
34
34
  *
35
- * @param config - Configuration containing the RevenueCat API keys and optional base URL.
35
+ * @param config - Configuration containing the RevenueCat API key and optional base URL.
36
36
  */
37
37
  constructor(config: SubscriptionHelperConfig);
38
38
  /**
@@ -50,7 +50,7 @@ export declare class SubscriptionHelper {
50
50
  * Get full subscription info including entitlements, subscription start date,
51
51
  * and platform.
52
52
  *
53
- * Queries each configured platform API key, filters out expired entitlements
53
+ * Fetches the subscriber data from RevenueCat, filters out expired entitlements
54
54
  * and (optionally) sandbox purchases, and returns the active entitlement names
55
55
  * along with the earliest purchase date and the platform it came from.
56
56
  *
@@ -60,15 +60,5 @@ export declare class SubscriptionHelper {
60
60
  * @throws Error if the RevenueCat API returns a non-404, non-OK response.
61
61
  */
62
62
  getSubscriptionInfo(userId: string, testMode?: boolean): Promise<SubscriptionInfo>;
63
- /**
64
- * Fetch subscriber info from RevenueCat for a single API key.
65
- *
66
- * For web/webSandbox keys, sandbox filtering is handled by key selection
67
- * in getSubscriptionInfo. For ios/android/macos keys, sandbox filtering
68
- * is done by checking the subscription's `environment` field.
69
- *
70
- * @returns Active entitlement names and earliest purchase date for this key.
71
- */
72
- private fetchSubscriberInfo;
73
63
  }
74
64
  //# sourceMappingURL=SubscriptionHelper.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SubscriptionHelper.d.ts","sourceRoot":"","sources":["../../src/helpers/SubscriptionHelper.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEjF;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,8CAA8C;IAC9C,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,6EAA6E;IAC7E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,uEAAuE;IACvE,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAcD;;;;;;;GAOG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAoB;IAC5C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IAEnC;;;;OAIG;gBACS,MAAM,EAAE,wBAAwB;IAM5C;;;;;;;;;OASG;IACG,eAAe,CACnB,MAAM,EAAE,MAAM,EACd,QAAQ,GAAE,OAAe,GACxB,OAAO,CAAC,MAAM,EAAE,CAAC;IASpB;;;;;;;;;;;;OAYG;IACG,mBAAmB,CACvB,MAAM,EAAE,MAAM,EACd,QAAQ,GAAE,OAAe,GACxB,OAAO,CAAC,gBAAgB,CAAC;IAsD5B;;;;;;;;OAQG;YACW,mBAAmB;CAsElC"}
1
+ {"version":3,"file":"SubscriptionHelper.d.ts","sourceRoot":"","sources":["../../src/helpers/SubscriptionHelper.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,sDAAsD;IACtD,gBAAgB,EAAE,MAAM,CAAC;IACzB,6EAA6E;IAC7E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,uEAAuE;IACvE,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAWD;;;;;;;GAOG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IAEnC;;;;OAIG;gBACS,MAAM,EAAE,wBAAwB;IAM5C;;;;;;;;;OASG;IACG,eAAe,CACnB,MAAM,EAAE,MAAM,EACd,QAAQ,GAAE,OAAe,GACxB,OAAO,CAAC,MAAM,EAAE,CAAC;IASpB;;;;;;;;;;;;OAYG;IACG,mBAAmB,CACvB,MAAM,EAAE,MAAM,EACd,QAAQ,GAAE,OAAe,GACxB,OAAO,CAAC,gBAAgB,CAAC;CAqF7B"}
@@ -6,30 +6,30 @@
6
6
  * filtering via the `testMode` parameter.
7
7
  */
8
8
  import { NONE_ENTITLEMENT, SubscriptionPlatform } from "@sudobility/types";
9
- /** Maps RevenueCatApiKeys fields to SubscriptionPlatform values. */
10
- const API_KEY_PLATFORM_MAP = [
11
- { key: "web", platform: SubscriptionPlatform.Web },
12
- { key: "webSandbox", platform: SubscriptionPlatform.Web },
13
- { key: "ios", platform: SubscriptionPlatform.iOS },
14
- { key: "android", platform: SubscriptionPlatform.Android },
15
- { key: "macos", platform: SubscriptionPlatform.macOS },
16
- ];
9
+ /** Maps RevenueCat store identifiers to SubscriptionPlatform values. */
10
+ const STORE_PLATFORM_MAP = {
11
+ stripe: SubscriptionPlatform.Web,
12
+ rc_billing: SubscriptionPlatform.Web,
13
+ app_store: SubscriptionPlatform.iOS,
14
+ play_store: SubscriptionPlatform.Android,
15
+ mac_app_store: SubscriptionPlatform.macOS,
16
+ };
17
17
  /**
18
18
  * Helper class for interacting with RevenueCat API to get user entitlements
19
19
  * and subscription information.
20
20
  *
21
21
  * Uses the RevenueCat REST API v1 endpoint `GET /subscribers/{user_id}` to
22
22
  * fetch subscriber data, then filters entitlements by expiration and sandbox status.
23
- * Queries each configured platform API key and merges the results.
23
+ * Detects the subscription platform from the store field in the response.
24
24
  */
25
25
  export class SubscriptionHelper {
26
26
  /**
27
27
  * Creates a new SubscriptionHelper instance.
28
28
  *
29
- * @param config - Configuration containing the RevenueCat API keys and optional base URL.
29
+ * @param config - Configuration containing the RevenueCat API key and optional base URL.
30
30
  */
31
31
  constructor(config) {
32
- this.apiKeys = config.revenueCatApiKeys;
32
+ this.apiKey = config.revenueCatApiKey;
33
33
  this.baseUrl = config.baseUrl ?? "https://api.revenuecat.com/v1";
34
34
  this.timeoutMs = config.timeoutMs ?? 10000;
35
35
  }
@@ -54,7 +54,7 @@ export class SubscriptionHelper {
54
54
  * Get full subscription info including entitlements, subscription start date,
55
55
  * and platform.
56
56
  *
57
- * Queries each configured platform API key, filters out expired entitlements
57
+ * Fetches the subscriber data from RevenueCat, filters out expired entitlements
58
58
  * and (optionally) sandbox purchases, and returns the active entitlement names
59
59
  * along with the earliest purchase date and the platform it came from.
60
60
  *
@@ -67,55 +67,6 @@ export class SubscriptionHelper {
67
67
  if (!userId || typeof userId !== "string") {
68
68
  throw new Error("userId must be a non-empty string");
69
69
  }
70
- const allEntitlements = [];
71
- let earliestPurchaseDate = null;
72
- let resultPlatform = null;
73
- for (const { key, platform } of API_KEY_PLATFORM_MAP) {
74
- const apiKey = this.apiKeys[key];
75
- if (!apiKey)
76
- continue;
77
- // In production mode, skip webSandbox key
78
- if (!testMode && key === "webSandbox")
79
- continue;
80
- // In test mode, skip web key (use webSandbox instead)
81
- if (testMode && key === "web" && this.apiKeys.webSandbox)
82
- continue;
83
- const result = await this.fetchSubscriberInfo(userId, apiKey, key, testMode);
84
- for (const name of result.entitlements) {
85
- if (!allEntitlements.includes(name)) {
86
- allEntitlements.push(name);
87
- }
88
- }
89
- if (result.purchaseDate) {
90
- if (!earliestPurchaseDate || result.purchaseDate < earliestPurchaseDate) {
91
- earliestPurchaseDate = result.purchaseDate;
92
- resultPlatform = platform;
93
- }
94
- }
95
- }
96
- if (allEntitlements.length === 0) {
97
- return {
98
- entitlements: [NONE_ENTITLEMENT],
99
- subscriptionStartedAt: null,
100
- platform: null,
101
- };
102
- }
103
- return {
104
- entitlements: allEntitlements,
105
- subscriptionStartedAt: earliestPurchaseDate,
106
- platform: resultPlatform,
107
- };
108
- }
109
- /**
110
- * Fetch subscriber info from RevenueCat for a single API key.
111
- *
112
- * For web/webSandbox keys, sandbox filtering is handled by key selection
113
- * in getSubscriptionInfo. For ios/android/macos keys, sandbox filtering
114
- * is done by checking the subscription's `environment` field.
115
- *
116
- * @returns Active entitlement names and earliest purchase date for this key.
117
- */
118
- async fetchSubscriberInfo(userId, apiKey, keyName, testMode) {
119
70
  const url = `${this.baseUrl}/subscribers/${encodeURIComponent(userId)}`;
120
71
  const controller = new AbortController();
121
72
  const timeoutId = setTimeout(() => controller.abort(), this.timeoutMs);
@@ -124,7 +75,7 @@ export class SubscriptionHelper {
124
75
  response = await fetch(url, {
125
76
  method: "GET",
126
77
  headers: {
127
- Authorization: `Bearer ${apiKey}`,
78
+ Authorization: `Bearer ${this.apiKey}`,
128
79
  "Content-Type": "application/json",
129
80
  },
130
81
  signal: controller.signal,
@@ -134,7 +85,11 @@ export class SubscriptionHelper {
134
85
  clearTimeout(timeoutId);
135
86
  }
136
87
  if (response.status === 404) {
137
- return { entitlements: [], purchaseDate: null };
88
+ return {
89
+ entitlements: [NONE_ENTITLEMENT],
90
+ subscriptionStartedAt: null,
91
+ platform: null,
92
+ };
138
93
  }
139
94
  if (!response.ok) {
140
95
  throw new Error(`RevenueCat API error: ${response.status} ${response.statusText}`);
@@ -145,24 +100,37 @@ export class SubscriptionHelper {
145
100
  const now = new Date();
146
101
  const activeEntitlements = [];
147
102
  let earliestPurchaseDate = null;
148
- // For ios/android/macos, filter by environment field
149
- const checkEnvironment = keyName === "ios" || keyName === "android" || keyName === "macos";
103
+ let resultPlatform = null;
150
104
  for (const [name, entitlement] of Object.entries(entitlements)) {
151
105
  const isActive = !entitlement.expires_date || new Date(entitlement.expires_date) > now;
152
106
  if (!isActive) {
153
107
  continue;
154
108
  }
155
109
  const subscription = subscriptions[entitlement.product_identifier];
156
- if (checkEnvironment && !testMode && subscription?.environment === "sandbox") {
110
+ // Filter sandbox purchases in production mode
111
+ if (!testMode && subscription?.environment === "sandbox") {
157
112
  continue;
158
113
  }
159
114
  activeEntitlements.push(name);
160
115
  const purchaseDate = new Date(entitlement.purchase_date);
161
116
  if (!earliestPurchaseDate || purchaseDate < earliestPurchaseDate) {
162
117
  earliestPurchaseDate = purchaseDate;
118
+ resultPlatform =
119
+ STORE_PLATFORM_MAP[subscription?.store ?? ""] ?? null;
163
120
  }
164
121
  }
165
- return { entitlements: activeEntitlements, purchaseDate: earliestPurchaseDate };
122
+ if (activeEntitlements.length === 0) {
123
+ return {
124
+ entitlements: [NONE_ENTITLEMENT],
125
+ subscriptionStartedAt: null,
126
+ platform: null,
127
+ };
128
+ }
129
+ return {
130
+ entitlements: activeEntitlements,
131
+ subscriptionStartedAt: earliestPurchaseDate,
132
+ platform: resultPlatform,
133
+ };
166
134
  }
167
135
  }
168
136
  //# sourceMappingURL=SubscriptionHelper.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SubscriptionHelper.js","sourceRoot":"","sources":["../../src/helpers/Subscri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SACzB,CAAC;IACJ,CAAC;CACF"}
package/dist/index.d.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  * Re-exports all types and the SubscriptionHelper class for server-side
5
5
  * subscription management via RevenueCat.
6
6
  */
7
- export { type RevenueCatApiKeys, type RevenueCatEntitlement, type RevenueCatSubscription, type RevenueCatSubscriberResponse, type SubscriptionInfo, } from "./types";
7
+ export { type RevenueCatEntitlement, type RevenueCatSubscription, type RevenueCatSubscriberResponse, type SubscriptionInfo, } from "./types";
8
8
  export { NONE_ENTITLEMENT } from "@sudobility/types";
9
9
  export { SubscriptionHelper, type SubscriptionHelperConfig, } from "./helpers";
10
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,KAAK,4BAA4B,EACjC,KAAK,gBAAgB,GACtB,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAGrD,OAAO,EACL,kBAAkB,EAClB,KAAK,wBAAwB,GAC9B,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,KAAK,4BAA4B,EACjC,KAAK,gBAAgB,GACtB,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAGrD,OAAO,EACL,kBAAkB,EAClB,KAAK,wBAAwB,GAC9B,MAAM,WAAW,CAAC"}
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAWH,oCAAoC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,UAAU;AACV,OAAO,EACL,kBAAkB,GAEnB,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAUH,oCAAoC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,UAAU;AACV,OAAO,EACL,kBAAkB,GAEnB,MAAM,WAAW,CAAC"}
@@ -2,5 +2,5 @@
2
2
  * @fileoverview Type re-exports for subscription_service.
3
3
  */
4
4
  export { type RevenueCatEntitlement, type RevenueCatSubscription, type RevenueCatSubscriberResponse, } from "./entitlements";
5
- export { type RevenueCatApiKeys, type SubscriptionInfo } from "./subscription";
5
+ export { type SubscriptionInfo } from "./subscription";
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,KAAK,4BAA4B,GAClC,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,KAAK,iBAAiB,EAAE,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,KAAK,4BAA4B,GAClC,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC"}
@@ -2,22 +2,6 @@
2
2
  * @fileoverview Domain types for subscription information returned by SubscriptionHelper.
3
3
  */
4
4
  import { SubscriptionPlatform } from "@sudobility/types";
5
- /**
6
- * RevenueCat API keys per platform. All fields are optional —
7
- * only platforms the app supports need to be provided.
8
- */
9
- export interface RevenueCatApiKeys {
10
- /** RevenueCat secret API key for web (Stripe) */
11
- web?: string;
12
- /** RevenueCat secret API key for web sandbox */
13
- webSandbox?: string;
14
- /** RevenueCat secret API key for iOS (App Store) */
15
- ios?: string;
16
- /** RevenueCat secret API key for Android (Play Store) */
17
- android?: string;
18
- /** RevenueCat secret API key for macOS (Mac App Store) */
19
- macos?: string;
20
- }
21
5
  /**
22
6
  * Subscription information returned by SubscriptionHelper.
23
7
  */
@@ -1 +1 @@
1
- {"version":3,"file":"subscription.d.ts","sourceRoot":"","sources":["../../src/types/subscription.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAEzD;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,iDAAiD;IACjD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,gDAAgD;IAChD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,oDAAoD;IACpD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,yDAAyD;IACzD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,0DAA0D;IAC1D,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,+EAA+E;IAC/E,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,yFAAyF;IACzF,qBAAqB,EAAE,IAAI,GAAG,IAAI,CAAC;IACnC,gFAAgF;IAChF,QAAQ,EAAE,oBAAoB,GAAG,IAAI,CAAC;CACvC"}
1
+ {"version":3,"file":"subscription.d.ts","sourceRoot":"","sources":["../../src/types/subscription.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAEzD;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,+EAA+E;IAC/E,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,yFAAyF;IACzF,qBAAqB,EAAE,IAAI,GAAG,IAAI,CAAC;IACnC,gFAAgF;IAChF,QAAQ,EAAE,oBAAoB,GAAG,IAAI,CAAC;CACvC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sudobility/subscription_service",
3
- "version": "1.0.12",
3
+ "version": "1.0.13",
4
4
  "author": "Sudobility",
5
5
  "main": "./dist/index.js",
6
6
  "devDependencies": {