@sudobility/ratelimit_service 1.0.1

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.
Files changed (67) hide show
  1. package/CLAUDE.md +160 -0
  2. package/dist/helpers/EntitlementHelper.cjs +75 -0
  3. package/dist/helpers/EntitlementHelper.d.ts +52 -0
  4. package/dist/helpers/EntitlementHelper.d.ts.map +1 -0
  5. package/dist/helpers/EntitlementHelper.js +75 -0
  6. package/dist/helpers/EntitlementHelper.js.map +1 -0
  7. package/dist/helpers/RateLimitChecker.cjs +264 -0
  8. package/dist/helpers/RateLimitChecker.d.ts +90 -0
  9. package/dist/helpers/RateLimitChecker.d.ts.map +1 -0
  10. package/dist/helpers/RateLimitChecker.js +264 -0
  11. package/dist/helpers/RateLimitChecker.js.map +1 -0
  12. package/dist/helpers/RateLimitRouteHandler.cjs +191 -0
  13. package/dist/helpers/RateLimitRouteHandler.d.ts +70 -0
  14. package/dist/helpers/RateLimitRouteHandler.d.ts.map +1 -0
  15. package/dist/helpers/RateLimitRouteHandler.js +191 -0
  16. package/dist/helpers/RateLimitRouteHandler.js.map +1 -0
  17. package/dist/helpers/RevenueCatHelper.cjs +96 -0
  18. package/dist/helpers/RevenueCatHelper.d.ts +51 -0
  19. package/dist/helpers/RevenueCatHelper.d.ts.map +1 -0
  20. package/dist/helpers/RevenueCatHelper.js +96 -0
  21. package/dist/helpers/RevenueCatHelper.js.map +1 -0
  22. package/dist/helpers/index.cjs +10 -0
  23. package/dist/helpers/index.d.ts +4 -0
  24. package/dist/helpers/index.d.ts.map +1 -0
  25. package/dist/helpers/index.js +10 -0
  26. package/dist/helpers/index.js.map +1 -0
  27. package/dist/index.cjs +36 -0
  28. package/dist/index.d.ts +9 -0
  29. package/dist/index.d.ts.map +1 -0
  30. package/dist/index.js +36 -0
  31. package/dist/index.js.map +1 -0
  32. package/dist/middleware/hono.cjs +94 -0
  33. package/dist/middleware/hono.d.ts +63 -0
  34. package/dist/middleware/hono.d.ts.map +1 -0
  35. package/dist/middleware/hono.js +94 -0
  36. package/dist/middleware/hono.js.map +1 -0
  37. package/dist/schema/rate-limits.cjs +136 -0
  38. package/dist/schema/rate-limits.d.ts +333 -0
  39. package/dist/schema/rate-limits.d.ts.map +1 -0
  40. package/dist/schema/rate-limits.js +136 -0
  41. package/dist/schema/rate-limits.js.map +1 -0
  42. package/dist/types/entitlements.cjs +9 -0
  43. package/dist/types/entitlements.d.ts +29 -0
  44. package/dist/types/entitlements.d.ts.map +1 -0
  45. package/dist/types/entitlements.js +9 -0
  46. package/dist/types/entitlements.js.map +1 -0
  47. package/dist/types/index.cjs +20 -0
  48. package/dist/types/index.d.ts +4 -0
  49. package/dist/types/index.d.ts.map +1 -0
  50. package/dist/types/index.js +20 -0
  51. package/dist/types/index.js.map +1 -0
  52. package/dist/types/rate-limits.cjs +3 -0
  53. package/dist/types/rate-limits.d.ts +34 -0
  54. package/dist/types/rate-limits.d.ts.map +1 -0
  55. package/dist/types/rate-limits.js +3 -0
  56. package/dist/types/rate-limits.js.map +1 -0
  57. package/dist/types/responses.cjs +13 -0
  58. package/dist/types/responses.d.ts +85 -0
  59. package/dist/types/responses.d.ts.map +1 -0
  60. package/dist/types/responses.js +13 -0
  61. package/dist/types/responses.js.map +1 -0
  62. package/dist/utils/time.cjs +180 -0
  63. package/dist/utils/time.d.ts +80 -0
  64. package/dist/utils/time.d.ts.map +1 -0
  65. package/dist/utils/time.js +180 -0
  66. package/dist/utils/time.js.map +1 -0
  67. package/package.json +79 -0
@@ -0,0 +1,191 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RateLimitRouteHandler = void 0;
4
+ const RevenueCatHelper_1 = require("./RevenueCatHelper");
5
+ const EntitlementHelper_1 = require("./EntitlementHelper");
6
+ const RateLimitChecker_1 = require("./RateLimitChecker");
7
+ const types_1 = require("../types");
8
+ /**
9
+ * Default display names for common entitlements.
10
+ */
11
+ const DEFAULT_DISPLAY_NAMES = {
12
+ none: "Free",
13
+ starter: "Starter",
14
+ pro: "Pro",
15
+ enterprise: "Enterprise",
16
+ };
17
+ /**
18
+ * Helper for rate limit API endpoints.
19
+ * Provides data for /ratelimits and /ratelimits/history endpoints.
20
+ */
21
+ class RateLimitRouteHandler {
22
+ constructor(config) {
23
+ this.rcHelper = new RevenueCatHelper_1.RevenueCatHelper({ apiKey: config.revenueCatApiKey });
24
+ this.entitlementHelper = new EntitlementHelper_1.EntitlementHelper(config.rateLimitsConfig);
25
+ this.rateLimitChecker = new RateLimitChecker_1.RateLimitChecker({
26
+ db: config.db,
27
+ table: config.rateLimitsTable,
28
+ });
29
+ this.rateLimitsConfig = config.rateLimitsConfig;
30
+ this.displayNames = {
31
+ ...DEFAULT_DISPLAY_NAMES,
32
+ ...config.entitlementDisplayNames,
33
+ };
34
+ }
35
+ /**
36
+ * Get rate limits configuration data for /ratelimits endpoint.
37
+ *
38
+ * @param userId - The user's ID (e.g., Firebase UID)
39
+ * @returns RateLimitsConfigData for API response
40
+ */
41
+ async getRateLimitsConfigData(userId) {
42
+ // Get all tiers from config
43
+ const tiers = Object.entries(this.rateLimitsConfig).map(([entitlement, limits]) => ({
44
+ entitlement,
45
+ displayName: this.getDisplayName(entitlement),
46
+ limits: this.convertLimits(limits),
47
+ }));
48
+ // Get user's subscription info from RevenueCat
49
+ let entitlements;
50
+ let subscriptionStartedAt = null;
51
+ try {
52
+ const subscriptionInfo = await this.rcHelper.getSubscriptionInfo(userId);
53
+ entitlements = subscriptionInfo.entitlements;
54
+ subscriptionStartedAt = subscriptionInfo.subscriptionStartedAt;
55
+ }
56
+ catch (error) {
57
+ console.error("RevenueCat error, using 'none' entitlement:", error);
58
+ entitlements = [types_1.NONE_ENTITLEMENT];
59
+ }
60
+ // Get the primary entitlement (first one that has limits configured)
61
+ const currentEntitlement = this.getPrimaryEntitlement(entitlements);
62
+ // Get rate limits for user's entitlements
63
+ const internalLimits = this.entitlementHelper.getRateLimits(entitlements);
64
+ const currentLimits = this.convertLimits(internalLimits);
65
+ // Get current usage
66
+ const checkResult = await this.rateLimitChecker.checkOnly(userId, internalLimits, subscriptionStartedAt);
67
+ const currentUsage = {
68
+ hourly: internalLimits.hourly !== undefined
69
+ ? internalLimits.hourly - (checkResult.remaining.hourly ?? 0)
70
+ : 0,
71
+ daily: internalLimits.daily !== undefined
72
+ ? internalLimits.daily - (checkResult.remaining.daily ?? 0)
73
+ : 0,
74
+ monthly: internalLimits.monthly !== undefined
75
+ ? internalLimits.monthly - (checkResult.remaining.monthly ?? 0)
76
+ : 0,
77
+ };
78
+ return {
79
+ tiers,
80
+ currentEntitlement,
81
+ currentLimits,
82
+ currentUsage,
83
+ };
84
+ }
85
+ /**
86
+ * Get rate limit history data for /ratelimits/history/{periodType} endpoint.
87
+ *
88
+ * @param userId - The user's ID (e.g., Firebase UID)
89
+ * @param periodType - The period type (hour, day, month)
90
+ * @param limit - Maximum number of entries to return (default: 100)
91
+ * @returns RateLimitHistoryData for API response
92
+ */
93
+ async getRateLimitHistoryData(userId, periodType, limit = 100) {
94
+ // Convert API period type to internal period type
95
+ const internalPeriodType = this.convertPeriodType(periodType);
96
+ // Get user's subscription info for subscription month calculation
97
+ let subscriptionStartedAt = null;
98
+ let entitlements = [types_1.NONE_ENTITLEMENT];
99
+ try {
100
+ const subscriptionInfo = await this.rcHelper.getSubscriptionInfo(userId);
101
+ subscriptionStartedAt = subscriptionInfo.subscriptionStartedAt;
102
+ entitlements = subscriptionInfo.entitlements;
103
+ }
104
+ catch (error) {
105
+ console.error("RevenueCat error:", error);
106
+ }
107
+ // Get the limit for this period type
108
+ const internalLimits = this.entitlementHelper.getRateLimits(entitlements);
109
+ const periodLimit = this.getLimitForPeriod(internalLimits, periodType);
110
+ // Get history from database
111
+ const history = await this.rateLimitChecker.getHistory(userId, internalPeriodType, subscriptionStartedAt, limit);
112
+ // Convert to API format
113
+ const entries = history.entries.map(entry => ({
114
+ periodStart: entry.period_start.toISOString(),
115
+ periodEnd: entry.period_end.toISOString(),
116
+ requestCount: entry.request_count,
117
+ limit: periodLimit,
118
+ }));
119
+ return {
120
+ periodType,
121
+ entries,
122
+ totalEntries: entries.length,
123
+ };
124
+ }
125
+ /**
126
+ * Get display name for an entitlement.
127
+ */
128
+ getDisplayName(entitlement) {
129
+ if (this.displayNames[entitlement]) {
130
+ return this.displayNames[entitlement];
131
+ }
132
+ // Capitalize first letter as fallback
133
+ return entitlement.charAt(0).toUpperCase() + entitlement.slice(1);
134
+ }
135
+ /**
136
+ * Get the primary entitlement from a list.
137
+ * Returns the first entitlement that has configured limits, or "none".
138
+ */
139
+ getPrimaryEntitlement(entitlements) {
140
+ for (const entitlement of entitlements) {
141
+ if (entitlement !== types_1.NONE_ENTITLEMENT &&
142
+ this.rateLimitsConfig[entitlement]) {
143
+ return entitlement;
144
+ }
145
+ }
146
+ return types_1.NONE_ENTITLEMENT;
147
+ }
148
+ /**
149
+ * Convert internal RateLimits to API RateLimits.
150
+ * Internal uses undefined for unlimited, API uses null.
151
+ */
152
+ convertLimits(limits) {
153
+ return {
154
+ hourly: limits.hourly ?? null,
155
+ daily: limits.daily ?? null,
156
+ monthly: limits.monthly ?? null,
157
+ };
158
+ }
159
+ /**
160
+ * Convert API period type to internal period type.
161
+ */
162
+ convertPeriodType(periodType) {
163
+ switch (periodType) {
164
+ case "hour":
165
+ return types_1.PeriodType.HOURLY;
166
+ case "day":
167
+ return types_1.PeriodType.DAILY;
168
+ case "month":
169
+ return types_1.PeriodType.MONTHLY;
170
+ default:
171
+ throw new Error(`Invalid period type: ${periodType}`);
172
+ }
173
+ }
174
+ /**
175
+ * Get the limit for a specific period type.
176
+ */
177
+ getLimitForPeriod(limits, periodType) {
178
+ switch (periodType) {
179
+ case "hour":
180
+ return limits.hourly ?? null;
181
+ case "day":
182
+ return limits.daily ?? null;
183
+ case "month":
184
+ return limits.monthly ?? null;
185
+ default:
186
+ return null;
187
+ }
188
+ }
189
+ }
190
+ exports.RateLimitRouteHandler = RateLimitRouteHandler;
191
+ //# sourceMappingURL=RateLimitRouteHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RateLimitRouteHandler.js","sourceRoot":"","sources":["../../src/helpers/RateLimitRouteHandler.ts"],"names":[],"mappings":";;;AAWA,yDAAsD;AACtD,2DAAwD;AACxD,yDAAsD;AACtD,oCAKkB;AAkBlB;;GAEG;AACH,MAAM,qBAAqB,GAA2B;IACpD,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,SAAS;IAClB,GAAG,EAAE,KAAK;IACV,UAAU,EAAE,YAAY;CACzB,CAAC;AAEF;;;GAGG;AACH,MAAa,qBAAqB;IAOhC,YAAY,MAAmC;QAC7C,IAAI,CAAC,QAAQ,GAAG,IAAI,mCAAgB,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,gBAAgB,EAAE,CAAC,CAAC;QAC1E,IAAI,CAAC,iBAAiB,GAAG,IAAI,qCAAiB,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;QACxE,IAAI,CAAC,gBAAgB,GAAG,IAAI,mCAAgB,CAAC;YAC3C,EAAE,EAAE,MAAM,CAAC,EAAE;YACb,KAAK,EAAE,MAAM,CAAC,eAAe;SAC9B,CAAC,CAAC;QACH,IAAI,CAAC,gBAAgB,GAAG,MAAM,CAAC,gBAAgB,CAAC;QAChD,IAAI,CAAC,YAAY,GAAG;YAClB,GAAG,qBAAqB;YACxB,GAAG,MAAM,CAAC,uBAAuB;SAClC,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,uBAAuB,CAAC,MAAc;QAC1C,4BAA4B;QAC5B,MAAM,KAAK,GAAoB,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,GAAG,CACtE,CAAC,CAAC,WAAW,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC;YAC1B,WAAW;YACX,WAAW,EAAE,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC;YAC7C,MAAM,EAAE,IAAI,C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AAO,kBAAU,CAAC,MAAM,CAAC;YAC3B,KAAK,KAAK;gBACR,OAAO,kBAAU,CAAC,KAAK,CAAC;YAC1B,KAAK,OAAO;gBACV,OAAO,kBAAU,CAAC,OAAO,CAAC;YAC5B;gBACE,MAAM,IAAI,KAAK,CAAC,wBAAwB,UAAU,EAAE,CAAC,CAAC;QAC1D,CAAC;IACH,CAAC;IAED;;OAEG;IACK,iBAAiB,CACvB,MAA0B,EAC1B,UAA+B;QAE/B,QAAQ,UAAU,EAAE,CAAC;YACnB,KAAK,MAAM;gBACT,OAAO,MAAM,CAAC,MAAM,IAAI,IAAI,CAAC;YAC/B,KAAK,KAAK;gBACR,OAAO,MAAM,CAAC,KAAK,IAAI,IAAI,CAAC;YAC9B,KAAK,OAAO;gBACV,OAAO,MAAM,CAAC,OAAO,IAAI,IAAI,CAAC;YAChC;gBACE,OAAO,IAAI,CAAC;QAChB,CAAC;IACH,CAAC;CACF;AArND,sDAqNC"}
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RevenueCatHelper = void 0;
4
+ const entitlements_1 = require("../types/entitlements");
5
+ /**
6
+ * Helper class for interacting with RevenueCat API to get user entitlements
7
+ * and subscription information.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * const rcHelper = new RevenueCatHelper({
12
+ * apiKey: process.env.REVENUECAT_API_KEY!,
13
+ * });
14
+ *
15
+ * // Get just entitlements (for backward compatibility)
16
+ * const entitlements = await rcHelper.getEntitlements(userId);
17
+ * // Returns: ["pro"] or ["none"] if no subscription
18
+ *
19
+ * // Get full subscription info including start date
20
+ * const info = await rcHelper.getSubscriptionInfo(userId);
21
+ * // Returns: { entitlements: ["pro"], subscriptionStartedAt: Date }
22
+ * ```
23
+ */
24
+ class RevenueCatHelper {
25
+ constructor(config) {
26
+ this.apiKey = config.apiKey;
27
+ this.baseUrl = config.baseUrl ?? "https://api.revenuecat.com/v1";
28
+ }
29
+ /**
30
+ * Get active entitlement names for a user.
31
+ *
32
+ * @param userId - The RevenueCat app_user_id (usually Firebase UID)
33
+ * @returns Array of active entitlement names, or ["none"] if no active entitlements
34
+ * @throws Error if RevenueCat API returns an error (other than 404)
35
+ */
36
+ async getEntitlements(userId) {
37
+ const info = await this.getSubscriptionInfo(userId);
38
+ return info.entitlements;
39
+ }
40
+ /**
41
+ * Get full subscription info including entitlements and subscription start date.
42
+ *
43
+ * @param userId - The RevenueCat app_user_id (usually Firebase UID)
44
+ * @returns SubscriptionInfo with entitlements and subscriptionStartedAt
45
+ * @throws Error if RevenueCat API returns an error (other than 404)
46
+ */
47
+ async getSubscriptionInfo(userId) {
48
+ const response = await fetch(`${this.baseUrl}/subscribers/${encodeURIComponent(userId)}`, {
49
+ method: "GET",
50
+ headers: {
51
+ Authorization: `Bearer ${this.apiKey}`,
52
+ "Content-Type": "application/json",
53
+ },
54
+ });
55
+ // User not found in RevenueCat - treat as no subscription
56
+ if (response.status === 404) {
57
+ return {
58
+ entitlements: [entitlements_1.NONE_ENTITLEMENT],
59
+ subscriptionStartedAt: null,
60
+ };
61
+ }
62
+ if (!response.ok) {
63
+ throw new Error(`RevenueCat API error: ${response.status} ${response.statusText}`);
64
+ }
65
+ const data = (await response.json());
66
+ const entitlements = data.subscriber?.entitlements ?? {};
67
+ const now = new Date();
68
+ const activeEntitlements = [];
69
+ let earliestPurchaseDate = null;
70
+ for (const [name, entitlement] of Object.entries(entitlements)) {
71
+ // Check if entitlement is active (no expiry or not expired)
72
+ const isActive = !entitlement.expires_date || new Date(entitlement.expires_date) > now;
73
+ if (isActive) {
74
+ activeEntitlements.push(name);
75
+ // Track earliest purchase date for subscription month calculation
76
+ const purchaseDate = new Date(entitlement.purchase_date);
77
+ if (!earliestPurchaseDate || purchaseDate < earliestPurchaseDate) {
78
+ earliestPurchaseDate = purchaseDate;
79
+ }
80
+ }
81
+ }
82
+ // If no active entitlements, return "none"
83
+ if (activeEntitlements.length === 0) {
84
+ return {
85
+ entitlements: [entitlements_1.NONE_ENTITLEMENT],
86
+ subscriptionStartedAt: null,
87
+ };
88
+ }
89
+ return {
90
+ entitlements: activeEntitlements,
91
+ subscriptionStartedAt: earliestPurchaseDate,
92
+ };
93
+ }
94
+ }
95
+ exports.RevenueCatHelper = RevenueCatHelper;
96
+ //# sourceMappingURL=RevenueCatHelper.js.map
@@ -0,0 +1,51 @@
1
+ import type { SubscriptionInfo } from "../types/responses";
2
+ /**
3
+ * Configuration for RevenueCatHelper.
4
+ */
5
+ export interface RevenueCatHelperConfig {
6
+ /** RevenueCat API key (secret key for server-side use) */
7
+ apiKey: string;
8
+ /** Base URL for RevenueCat API. Defaults to https://api.revenuecat.com/v1 */
9
+ baseUrl?: string;
10
+ }
11
+ /**
12
+ * Helper class for interacting with RevenueCat API to get user entitlements
13
+ * and subscription information.
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * const rcHelper = new RevenueCatHelper({
18
+ * apiKey: process.env.REVENUECAT_API_KEY!,
19
+ * });
20
+ *
21
+ * // Get just entitlements (for backward compatibility)
22
+ * const entitlements = await rcHelper.getEntitlements(userId);
23
+ * // Returns: ["pro"] or ["none"] if no subscription
24
+ *
25
+ * // Get full subscription info including start date
26
+ * const info = await rcHelper.getSubscriptionInfo(userId);
27
+ * // Returns: { entitlements: ["pro"], subscriptionStartedAt: Date }
28
+ * ```
29
+ */
30
+ export declare class RevenueCatHelper {
31
+ private readonly apiKey;
32
+ private readonly baseUrl;
33
+ constructor(config: RevenueCatHelperConfig);
34
+ /**
35
+ * Get active entitlement names for a user.
36
+ *
37
+ * @param userId - The RevenueCat app_user_id (usually Firebase UID)
38
+ * @returns Array of active entitlement names, or ["none"] if no active entitlements
39
+ * @throws Error if RevenueCat API returns an error (other than 404)
40
+ */
41
+ getEntitlements(userId: string): Promise<string[]>;
42
+ /**
43
+ * Get full subscription info including entitlements and subscription start date.
44
+ *
45
+ * @param userId - The RevenueCat app_user_id (usually Firebase UID)
46
+ * @returns SubscriptionInfo with entitlements and subscriptionStartedAt
47
+ * @throws Error if RevenueCat API returns an error (other than 404)
48
+ */
49
+ getSubscriptionInfo(userId: string): Promise<SubscriptionInfo>;
50
+ }
51
+ //# sourceMappingURL=RevenueCatHelper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RevenueCatHelper.d.ts","sourceRoot":"","sources":["../../src/helpers/RevenueCatHelper.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,0DAA0D;IAC1D,MAAM,EAAE,MAAM,CAAC;IACf,6EAA6E;IAC7E,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;gBAErB,MAAM,EAAE,sBAAsB;IAK1C;;;;;;OAMG;IACG,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAKxD;;;;;;OAMG;IACG,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;CA8DrE"}
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RevenueCatHelper = void 0;
4
+ const entitlements_1 = require("../types/entitlements");
5
+ /**
6
+ * Helper class for interacting with RevenueCat API to get user entitlements
7
+ * and subscription information.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * const rcHelper = new RevenueCatHelper({
12
+ * apiKey: process.env.REVENUECAT_API_KEY!,
13
+ * });
14
+ *
15
+ * // Get just entitlements (for backward compatibility)
16
+ * const entitlements = await rcHelper.getEntitlements(userId);
17
+ * // Returns: ["pro"] or ["none"] if no subscription
18
+ *
19
+ * // Get full subscription info including start date
20
+ * const info = await rcHelper.getSubscriptionInfo(userId);
21
+ * // Returns: { entitlements: ["pro"], subscriptionStartedAt: Date }
22
+ * ```
23
+ */
24
+ class RevenueCatHelper {
25
+ constructor(config) {
26
+ this.apiKey = config.apiKey;
27
+ this.baseUrl = config.baseUrl ?? "https://api.revenuecat.com/v1";
28
+ }
29
+ /**
30
+ * Get active entitlement names for a user.
31
+ *
32
+ * @param userId - The RevenueCat app_user_id (usually Firebase UID)
33
+ * @returns Array of active entitlement names, or ["none"] if no active entitlements
34
+ * @throws Error if RevenueCat API returns an error (other than 404)
35
+ */
36
+ async getEntitlements(userId) {
37
+ const info = await this.getSubscriptionInfo(userId);
38
+ return info.entitlements;
39
+ }
40
+ /**
41
+ * Get full subscription info including entitlements and subscription start date.
42
+ *
43
+ * @param userId - The RevenueCat app_user_id (usually Firebase UID)
44
+ * @returns SubscriptionInfo with entitlements and subscriptionStartedAt
45
+ * @throws Error if RevenueCat API returns an error (other than 404)
46
+ */
47
+ async getSubscriptionInfo(userId) {
48
+ const response = await fetch(`${this.baseUrl}/subscribers/${encodeURIComponent(userId)}`, {
49
+ method: "GET",
50
+ headers: {
51
+ Authorization: `Bearer ${this.apiKey}`,
52
+ "Content-Type": "application/json",
53
+ },
54
+ });
55
+ // User not found in RevenueCat - treat as no subscription
56
+ if (response.status === 404) {
57
+ return {
58
+ entitlements: [entitlements_1.NONE_ENTITLEMENT],
59
+ subscriptionStartedAt: null,
60
+ };
61
+ }
62
+ if (!response.ok) {
63
+ throw new Error(`RevenueCat API error: ${response.status} ${response.statusText}`);
64
+ }
65
+ const data = (await response.json());
66
+ const entitlements = data.subscriber?.entitlements ?? {};
67
+ const now = new Date();
68
+ const activeEntitlements = [];
69
+ let earliestPurchaseDate = null;
70
+ for (const [name, entitlement] of Object.entries(entitlements)) {
71
+ // Check if entitlement is active (no expiry or not expired)
72
+ const isActive = !entitlement.expires_date || new Date(entitlement.expires_date) > now;
73
+ if (isActive) {
74
+ activeEntitlements.push(name);
75
+ // Track earliest purchase date for subscription month calculation
76
+ const purchaseDate = new Date(entitlement.purchase_date);
77
+ if (!earliestPurchaseDate || purchaseDate < earliestPurchaseDate) {
78
+ earliestPurchaseDate = purchaseDate;
79
+ }
80
+ }
81
+ }
82
+ // If no active entitlements, return "none"
83
+ if (activeEntitlements.length === 0) {
84
+ return {
85
+ entitlements: [entitlements_1.NONE_ENTITLEMENT],
86
+ subscriptionStartedAt: null,
87
+ };
88
+ }
89
+ return {
90
+ entitlements: activeEntitlements,
91
+ subscriptionStartedAt: earliestPurchaseDate,
92
+ };
93
+ }
94
+ }
95
+ exports.RevenueCatHelper = RevenueCatHelper;
96
+ //# sourceMappingURL=RevenueCatHelper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RevenueCatHelper.js","sourceRoot":"","sources":["../../src/helpers/RevenueCatHelper.ts"],"names":[],"mappings":";;;AAAA,wDAG+B;AAa/B;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAa,gBAAgB;IAI3B,YAAY,MAA8B;QACxC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,+BAA+B,CAAC;IACnE,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,eAAe,CAAC,MAAc;QAClC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC;QACpD,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,mBAAmB,CAAC,MAAc;QACtC,MAAM,QAAQ,GAAG,MAAM,KAAK,CAC1B,GAAG,IAAI,CAAC,OAAO,gBAAgB,kBAAkB,CAAC,MAAM,CAAC,EAAE,EAC3D;YACE,MAAM,EAAE,KAAK;YACb,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,IAAI,CAAC,MAAM,EAAE;gBACtC,cAAc,EAAE,kBAAkB;aACnC;SACF,C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YACpC,OAAO;gBACL,YAAY,EAAE,CAAC,+BAAgB,CAAC;gBAChC,qBAAqB,EAAE,IAAI;aAC5B,CAAC;QACJ,CAAC;QAED,OAAO;YACL,YAAY,EAAE,kBAAkB;YAChC,qBAAqB,EAAE,oBAAoB;SAC5C,CAAC;IACJ,CAAC;CACF;AA1FD,4CA0FC"}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RateLimitChecker = exports.EntitlementHelper = exports.RevenueCatHelper = void 0;
4
+ var RevenueCatHelper_1 = require("./RevenueCatHelper");
5
+ Object.defineProperty(exports, "RevenueCatHelper", { enumerable: true, get: function () { return RevenueCatHelper_1.RevenueCatHelper; } });
6
+ var EntitlementHelper_1 = require("./EntitlementHelper");
7
+ Object.defineProperty(exports, "EntitlementHelper", { enumerable: true, get: function () { return EntitlementHelper_1.EntitlementHelper; } });
8
+ var RateLimitChecker_1 = require("./RateLimitChecker");
9
+ Object.defineProperty(exports, "RateLimitChecker", { enumerable: true, get: function () { return RateLimitChecker_1.RateLimitChecker; } });
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,4 @@
1
+ export { RevenueCatHelper, type RevenueCatHelperConfig, } from "./RevenueCatHelper";
2
+ export { EntitlementHelper } from "./EntitlementHelper";
3
+ export { RateLimitChecker, type RateLimitCheckerConfig, } from "./RateLimitChecker";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,KAAK,sBAAsB,GAC5B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EACL,gBAAgB,EAChB,KAAK,sBAAsB,GAC5B,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RateLimitChecker = exports.EntitlementHelper = exports.RevenueCatHelper = void 0;
4
+ var RevenueCatHelper_1 = require("./RevenueCatHelper");
5
+ Object.defineProperty(exports, "RevenueCatHelper", { enumerable: true, get: function () { return RevenueCatHelper_1.RevenueCatHelper; } });
6
+ var EntitlementHelper_1 = require("./EntitlementHelper");
7
+ Object.defineProperty(exports, "EntitlementHelper", { enumerable: true, get: function () { return EntitlementHelper_1.EntitlementHelper; } });
8
+ var RateLimitChecker_1 = require("./RateLimitChecker");
9
+ Object.defineProperty(exports, "RateLimitChecker", { enumerable: true, get: function () { return RateLimitChecker_1.RateLimitChecker; } });
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":";;;AAAA,uDAG4B;AAF1B,oHAAA,gBAAgB,OAAA;AAGlB,yDAAwD;AAA/C,sHAAA,iBAAiB,OAAA;AAC1B,uDAG4B;AAF1B,oHAAA,gBAAgB,OAAA"}
package/dist/index.cjs ADDED
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.createRateLimitMiddleware = exports.RateLimitRouteHandler = exports.RateLimitChecker = exports.EntitlementHelper = exports.RevenueCatHelper = void 0;
18
+ // Types
19
+ __exportStar(require("./types"), exports);
20
+ // Schema template
21
+ __exportStar(require("./schema/rate-limits"), exports);
22
+ // Helpers
23
+ var RevenueCatHelper_1 = require("./helpers/RevenueCatHelper");
24
+ Object.defineProperty(exports, "RevenueCatHelper", { enumerable: true, get: function () { return RevenueCatHelper_1.RevenueCatHelper; } });
25
+ var EntitlementHelper_1 = require("./helpers/EntitlementHelper");
26
+ Object.defineProperty(exports, "EntitlementHelper", { enumerable: true, get: function () { return EntitlementHelper_1.EntitlementHelper; } });
27
+ var RateLimitChecker_1 = require("./helpers/RateLimitChecker");
28
+ Object.defineProperty(exports, "RateLimitChecker", { enumerable: true, get: function () { return RateLimitChecker_1.RateLimitChecker; } });
29
+ var RateLimitRouteHandler_1 = require("./helpers/RateLimitRouteHandler");
30
+ Object.defineProperty(exports, "RateLimitRouteHandler", { enumerable: true, get: function () { return RateLimitRouteHandler_1.RateLimitRouteHandler; } });
31
+ // Middleware
32
+ var hono_1 = require("./middleware/hono");
33
+ Object.defineProperty(exports, "createRateLimitMiddleware", { enumerable: true, get: function () { return hono_1.createRateLimitMiddleware; } });
34
+ // Utilities
35
+ __exportStar(require("./utils/time"), exports);
36
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,9 @@
1
+ export * from "./types";
2
+ export * from "./schema/rate-limits";
3
+ export { RevenueCatHelper, type RevenueCatHelperConfig, } from "./helpers/RevenueCatHelper";
4
+ export { EntitlementHelper } from "./helpers/EntitlementHelper";
5
+ export { RateLimitChecker, type RateLimitCheckerConfig, } from "./helpers/RateLimitChecker";
6
+ export { RateLimitRouteHandler, type RateLimitRouteHandlerConfig, } from "./helpers/RateLimitRouteHandler";
7
+ export { createRateLimitMiddleware, type RateLimitMiddlewareConfig, } from "./middleware/hono";
8
+ export * from "./utils/time";
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,SAAS,CAAC;AAGxB,cAAc,sBAAsB,CAAC;AAGrC,OAAO,EACL,gBAAgB,EAChB,KAAK,sBAAsB,GAC5B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EACL,gBAAgB,EAChB,KAAK,sBAAsB,GAC5B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,qBAAqB,EACrB,KAAK,2BAA2B,GACjC,MAAM,iCAAiC,CAAC;AAGzC,OAAO,EACL,yBAAyB,EACzB,KAAK,yBAAyB,GAC/B,MAAM,mBAAmB,CAAC;AAG3B,cAAc,cAAc,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.createRateLimitMiddleware = exports.RateLimitRouteHandler = exports.RateLimitChecker = exports.EntitlementHelper = exports.RevenueCatHelper = void 0;
18
+ // Types
19
+ __exportStar(require("./types"), exports);
20
+ // Schema template
21
+ __exportStar(require("./schema/rate-limits"), exports);
22
+ // Helpers
23
+ var RevenueCatHelper_1 = require("./helpers/RevenueCatHelper");
24
+ Object.defineProperty(exports, "RevenueCatHelper", { enumerable: true, get: function () { return RevenueCatHelper_1.RevenueCatHelper; } });
25
+ var EntitlementHelper_1 = require("./helpers/EntitlementHelper");
26
+ Object.defineProperty(exports, "EntitlementHelper", { enumerable: true, get: function () { return EntitlementHelper_1.EntitlementHelper; } });
27
+ var RateLimitChecker_1 = require("./helpers/RateLimitChecker");
28
+ Object.defineProperty(exports, "RateLimitChecker", { enumerable: true, get: function () { return RateLimitChecker_1.RateLimitChecker; } });
29
+ var RateLimitRouteHandler_1 = require("./helpers/RateLimitRouteHandler");
30
+ Object.defineProperty(exports, "RateLimitRouteHandler", { enumerable: true, get: function () { return RateLimitRouteHandler_1.RateLimitRouteHandler; } });
31
+ // Middleware
32
+ var hono_1 = require("./middleware/hono");
33
+ Object.defineProperty(exports, "createRateLimitMiddleware", { enumerable: true, get: function () { return hono_1.createRateLimitMiddleware; } });
34
+ // Utilities
35
+ __exportStar(require("./utils/time"), exports);
36
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,QAAQ;AACR,0CAAwB;AAExB,kBAAkB;AAClB,uDAAqC;AAErC,UAAU;AACV,+DAGoC;AAFlC,oHAAA,gBAAgB,OAAA;AAGlB,iEAAgE;AAAvD,sHAAA,iBAAiB,OAAA;AAC1B,+DAGoC;AAFlC,oHAAA,gBAAgB,OAAA;AAGlB,yEAGyC;AAFvC,8HAAA,qBAAqB,OAAA;AAIvB,aAAa;AACb,0CAG2B;AAFzB,iHAAA,yBAAyB,OAAA;AAI3B,YAAY;AACZ,+CAA6B"}