@monetize.software/sdk 3.0.0-alpha.6 → 3.0.0-alpha.7
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/README.md +34 -13
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
# @monetize.software/sdk
|
|
2
2
|
|
|
3
|
-
SDK 3.0 — bundled billing client and paywall render engine.
|
|
4
|
-
|
|
3
|
+
SDK 3.0 — bundled billing client and paywall render engine. Renders the paywall
|
|
4
|
+
in a Shadow DOM modal on your page, with no iframe.
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
- **Websites:** install via npm and bundle, or load from a CDN (`esm.sh`/`unpkg`/`jsDelivr`).
|
|
7
|
+
- **Chrome extensions:** use the dedicated [`@monetize.software/sdk-extension`](https://www.npmjs.com/package/@monetize.software/sdk-extension)
|
|
8
|
+
package and bundle as an npm dependency — Chrome Web Store MV3 policy forbids
|
|
9
|
+
remote code execution, so CDN loading is **not** allowed.
|
|
10
|
+
|
|
11
|
+
Status: **alpha**. API surface is stabilizing but may still shift between alpha
|
|
12
|
+
releases; see [CHANGELOG.md](CHANGELOG.md).
|
|
7
13
|
|
|
8
14
|
## Three entrypoints
|
|
9
15
|
|
|
@@ -25,6 +31,7 @@ import { PaywallUI } from '@monetize.software/sdk';
|
|
|
25
31
|
|
|
26
32
|
const paywall = new PaywallUI({
|
|
27
33
|
paywallId: 'pw_abc123',
|
|
34
|
+
apiOrigin: 'https://your-paywall-domain.com', // required: your custom_domain
|
|
28
35
|
identity: { email: user.email, userId: user.id }
|
|
29
36
|
});
|
|
30
37
|
|
|
@@ -35,6 +42,10 @@ paywall.on('checkout_started', ({ url }) => {
|
|
|
35
42
|
document.getElementById('upgrade').onclick = () => paywall.open();
|
|
36
43
|
```
|
|
37
44
|
|
|
45
|
+
`apiOrigin` must match the `custom_domain` configured for your paywall in the
|
|
46
|
+
platform. The SDK validates it against the bootstrap response and throws
|
|
47
|
+
`invalid_config` on mismatch.
|
|
48
|
+
|
|
38
49
|
## Scripts
|
|
39
50
|
|
|
40
51
|
```bash
|
|
@@ -53,8 +64,8 @@ pnpm test
|
|
|
53
64
|
- **Tailwind v4**, compiled into a CSS string and injected into the shadow root.
|
|
54
65
|
- **Server-driven layout** — JSON schema of blocks (`heading`, `price_grid`, `cta_button`, ...).
|
|
55
66
|
SDK knows how to render blocks; the server controls order, copy, and visibility.
|
|
56
|
-
- **Server-driven checkout** — SDK is provider-agnostic (Stripe
|
|
57
|
-
it just opens the `checkout_url` returned by the server.
|
|
67
|
+
- **Server-driven checkout** — SDK is provider-agnostic (Stripe, Paddle, Freemius,
|
|
68
|
+
Chargebee, Overpay), it just opens the `checkout_url` returned by the server.
|
|
58
69
|
|
|
59
70
|
## Metered AI proxy (`ApiGatewayClient`)
|
|
60
71
|
|
|
@@ -65,8 +76,8 @@ this proxy and maintains local balance state.
|
|
|
65
76
|
```ts
|
|
66
77
|
import { BillingClient, AuthClient, QuotaExceededError } from '@monetize.software/sdk/core';
|
|
67
78
|
|
|
68
|
-
const auth = new AuthClient({ paywallId: 'pw_abc' });
|
|
69
|
-
const billing = new BillingClient({ paywallId: 'pw_abc', auth });
|
|
79
|
+
const auth = new AuthClient({ paywallId: 'pw_abc', apiOrigin: 'https://your-paywall-domain.com' });
|
|
80
|
+
const billing = new BillingClient({ paywallId: 'pw_abc', apiOrigin: 'https://your-paywall-domain.com', auth });
|
|
70
81
|
const gateway = billing.createApiGatewayClient();
|
|
71
82
|
|
|
72
83
|
billing.onBalanceChange((balances) => {
|
|
@@ -98,9 +109,19 @@ try {
|
|
|
98
109
|
`.body.getReader()`, or async-iter — anything that works on a `fetch` Response.
|
|
99
110
|
- On 402, `QuotaExceededError` is thrown with `balances` / `queryType` / `currentBalance`.
|
|
100
111
|
|
|
101
|
-
##
|
|
102
|
-
|
|
103
|
-
- Auth layer (Google
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
-
|
|
112
|
+
## What's included
|
|
113
|
+
|
|
114
|
+
- **Auth layer** — Email/password, OAuth (Google, Apple, Facebook, GitHub),
|
|
115
|
+
password reset and OTP confirmation flows. Lazy-loaded chunk: pay for it only
|
|
116
|
+
if you instantiate `AuthClient` or open the SDK with `auth: true`.
|
|
117
|
+
- **Trials** — time-based trial counter (LocalTrialStore on web,
|
|
118
|
+
RemoteTrialStore in the extension offscreen) with server-side validation.
|
|
119
|
+
- **Localization** — 27 bundled locales, lazy-loaded per active language; falls
|
|
120
|
+
back to canonical English baked into block strings.
|
|
121
|
+
- **Server-driven layout** — blocks, ordering, copy and visibility are owned by
|
|
122
|
+
the platform; the SDK renders. Live preview API for the admin editor.
|
|
123
|
+
- **React bindings** — see [`@monetize.software/sdk-react`](https://www.npmjs.com/package/@monetize.software/sdk-react)
|
|
124
|
+
for `<PaywallProvider>`, hooks and declarative gate/button components.
|
|
125
|
+
- **Chrome extensions** — see [`@monetize.software/sdk-extension`](https://www.npmjs.com/package/@monetize.software/sdk-extension)
|
|
126
|
+
for the offscreen-backed integration (single source of truth across tabs,
|
|
127
|
+
popups, side panels).
|
package/package.json
CHANGED