@entitlehub/sdk 0.1.0 → 0.1.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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,26 @@
1
+ # Changelog
2
+
3
+ All notable changes to `@entitlehub/sdk`. Adheres to [Semantic Versioning](https://semver.org/).
4
+
5
+ ## 0.1.1 — 2026-07-18
6
+
7
+ ### Added
8
+ - README badges (npm version, types, zero-deps, license) and docs links.
9
+ - `LICENSE` (MIT) and this changelog now ship in the package.
10
+
11
+ ### Docs
12
+ - `reportPurchase` examples cover all three modes: Google Play (validated via `purchaseToken`
13
+ + `isSubscription`), Apple StoreKit 2 (validated via `signedTransaction`), and trusted
14
+ server-report.
15
+
16
+ ## 0.1.0 — 2026-07-18
17
+
18
+ Initial release.
19
+
20
+ - **`EntitleHub`** (client, publishable key) — `getCustomerInfo`, `isEntitled`,
21
+ `checkEntitlement`, `getOfferings`, `logIn` / `logOut`, `addCustomerInfoUpdateListener`.
22
+ Cached CustomerInfo; safe for browsers, React Native, and Expo.
23
+ - **`EntitleHubServer`** (server, secret key) — `reportPurchase` (Apple JWS / Google Play
24
+ token / trusted), `grantEntitlement`, `getCustomerInfo`, `check`.
25
+ - **`CustomerInfo`** ergonomic wrapper; **`EntitleHubError`** with `.status` / `.code`.
26
+ - Zero dependencies; ESM + CJS + bundled type declarations.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 EntitleHub
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,7 +1,14 @@
1
1
  # @entitlehub/sdk
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/@entitlehub/sdk)](https://www.npmjs.com/package/@entitlehub/sdk)
4
+ [![types included](https://img.shields.io/npm/types/@entitlehub/sdk)](https://www.npmjs.com/package/@entitlehub/sdk)
5
+ [![zero dependencies](https://img.shields.io/badge/dependencies-0-brightgreen)](https://www.npmjs.com/package/@entitlehub/sdk)
6
+ [![license MIT](https://img.shields.io/npm/l/@entitlehub/sdk)](./LICENSE)
7
+
3
8
  One entitlement API across **App Store, Google Play, Stripe, and web** — for browsers, React Native, Expo, and Node. Stop checking raw product IDs; ask *"what is this user entitled to right now?"*
4
9
 
10
+ > Docs: **[entitlehub.com/docs](https://entitlehub.com/docs)** · [REST API](https://entitlehub.com/docs/api) · [Migrating from RevenueCat](https://entitlehub.com/docs/migrating-from-revenuecat)
11
+
5
12
  ```bash
6
13
  npm install @entitlehub/sdk
7
14
  ```
@@ -68,20 +75,27 @@ import { EntitleHubServer } from "@entitlehub/sdk";
68
75
 
69
76
  const eh = new EntitleHubServer({ apiKey: process.env.ENTITLEHUB_SECRET_KEY! });
70
77
 
71
- // After the store purchase is confirmed on-device, report it from your server:
78
+ // After the store purchase is confirmed on-device, report it from your server.
79
+ // Google Play — validated (EntitleHub verifies the token with your Play service account):
72
80
  const info = await eh.reportPurchase(userId, {
73
- store: "app_store",
74
- storeProductId: "pro_monthly",
81
+ store: "play", storeProductId: "pro_monthly",
82
+ purchaseToken: playToken, isSubscription: true,
75
83
  });
76
84
  info.isActive("pro"); // → true
77
85
 
86
+ // Apple StoreKit 2 — validated (product / environment read from the signed JWS):
87
+ await eh.reportPurchase(userId, { store: "app_store", storeProductId: "", signedTransaction: jws });
88
+
89
+ // Trusted server-report (no store validation — only if you validated the receipt elsewhere):
90
+ await eh.reportPurchase(userId, { store: "app_store", storeProductId: "pro_monthly" });
91
+
78
92
  // Grant directly (promo / comp / support), no purchase:
79
93
  await eh.grantEntitlement(userId, "pro", { durationDays: 30 });
80
94
  ```
81
95
 
82
96
  | Method | Returns |
83
97
  |---|---|
84
- | `reportPurchase(userId, { store, storeProductId, isSandbox?, transactionId? })` | `CustomerInfo` |
98
+ | `reportPurchase(userId, { store, storeProductId, purchaseToken?, isSubscription?, signedTransaction?, isSandbox?, transactionId? })` | `CustomerInfo` |
85
99
  | `grantEntitlement(userId, id, { durationDays?, isSandbox? })` | `CustomerInfo` |
86
100
  | `getCustomerInfo(userId)` / `check(userId, id)` | `CustomerInfo` / `CheckResult` |
87
101
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@entitlehub/sdk",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "EntitleHub SDK — one entitlement API across App Store, Google Play, Stripe, and web. Works in browsers, React Native, Expo, and Node.",
5
5
  "keywords": [
6
6
  "entitlehub",
@@ -28,7 +28,9 @@
28
28
  },
29
29
  "files": [
30
30
  "dist",
31
- "README.md"
31
+ "README.md",
32
+ "CHANGELOG.md",
33
+ "LICENSE"
32
34
  ],
33
35
  "sideEffects": false,
34
36
  "scripts": {