@monetize.software/sdk 3.0.0-alpha.2 → 3.0.0-alpha.20

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 (129) hide show
  1. package/README.md +34 -13
  2. package/dist/chunks/PaywallUI-BXEOgPTK.js +3555 -0
  3. package/dist/chunks/PaywallUI-BXEOgPTK.js.map +1 -0
  4. package/dist/chunks/PaywallUI-Cybo6wdO.js +26 -0
  5. package/dist/chunks/PaywallUI-Cybo6wdO.js.map +1 -0
  6. package/dist/chunks/ar-OnxZkqWR.js +2 -0
  7. package/dist/chunks/ar-OnxZkqWR.js.map +1 -0
  8. package/dist/chunks/ar-rSKgwKvp.js +129 -0
  9. package/dist/chunks/ar-rSKgwKvp.js.map +1 -0
  10. package/dist/chunks/cs-Cb2KZ70r.js +2 -0
  11. package/dist/chunks/cs-Cb2KZ70r.js.map +1 -0
  12. package/dist/chunks/cs-DIWkcge_.js +125 -0
  13. package/dist/chunks/cs-DIWkcge_.js.map +1 -0
  14. package/dist/chunks/da-DdMW98j3.js +125 -0
  15. package/dist/chunks/da-DdMW98j3.js.map +1 -0
  16. package/dist/chunks/da-DyQC12xy.js +2 -0
  17. package/dist/chunks/da-DyQC12xy.js.map +1 -0
  18. package/dist/chunks/de-CWM13wnK.js +2 -0
  19. package/dist/chunks/de-CWM13wnK.js.map +1 -0
  20. package/dist/chunks/de-D1bSmD_-.js +144 -0
  21. package/dist/chunks/de-D1bSmD_-.js.map +1 -0
  22. package/dist/chunks/el-BtKuORsc.js +2 -0
  23. package/dist/chunks/el-BtKuORsc.js.map +1 -0
  24. package/dist/chunks/el-C4LtWpfP.js +129 -0
  25. package/dist/chunks/el-C4LtWpfP.js.map +1 -0
  26. package/dist/chunks/es-Bhx7w85J.js +144 -0
  27. package/dist/chunks/es-Bhx7w85J.js.map +1 -0
  28. package/dist/chunks/es-qLcKnBft.js +2 -0
  29. package/dist/chunks/es-qLcKnBft.js.map +1 -0
  30. package/dist/chunks/fi-C34Oc6rg.js +125 -0
  31. package/dist/chunks/fi-C34Oc6rg.js.map +1 -0
  32. package/dist/chunks/fi-kGtbK51C.js +2 -0
  33. package/dist/chunks/fi-kGtbK51C.js.map +1 -0
  34. package/dist/chunks/fr-BrWtqej3.js +144 -0
  35. package/dist/chunks/fr-BrWtqej3.js.map +1 -0
  36. package/dist/chunks/fr-CScwFVNj.js +2 -0
  37. package/dist/chunks/fr-CScwFVNj.js.map +1 -0
  38. package/dist/chunks/he-Byr2r07x.js +129 -0
  39. package/dist/chunks/he-Byr2r07x.js.map +1 -0
  40. package/dist/chunks/he-ChFVbP_S.js +2 -0
  41. package/dist/chunks/he-ChFVbP_S.js.map +1 -0
  42. package/dist/chunks/hi-BIswPYL2.js +2 -0
  43. package/dist/chunks/hi-BIswPYL2.js.map +1 -0
  44. package/dist/chunks/hi-CABVgpKU.js +129 -0
  45. package/dist/chunks/hi-CABVgpKU.js.map +1 -0
  46. package/dist/chunks/hu-CSQ9avfJ.js +125 -0
  47. package/dist/chunks/hu-CSQ9avfJ.js.map +1 -0
  48. package/dist/chunks/hu-CT_jwL0k.js +2 -0
  49. package/dist/chunks/hu-CT_jwL0k.js.map +1 -0
  50. package/dist/chunks/id-2lYf7ogC.js +2 -0
  51. package/dist/chunks/id-2lYf7ogC.js.map +1 -0
  52. package/dist/chunks/id-BJ5w6RSU.js +125 -0
  53. package/dist/chunks/id-BJ5w6RSU.js.map +1 -0
  54. package/dist/chunks/it-CEMhCvXU.js +2 -0
  55. package/dist/chunks/it-CEMhCvXU.js.map +1 -0
  56. package/dist/chunks/it-Df8ChmTK.js +144 -0
  57. package/dist/chunks/it-Df8ChmTK.js.map +1 -0
  58. package/dist/chunks/ja-CkpO3n78.js +2 -0
  59. package/dist/chunks/ja-CkpO3n78.js.map +1 -0
  60. package/dist/chunks/ja-a53E5b2s.js +148 -0
  61. package/dist/chunks/ja-a53E5b2s.js.map +1 -0
  62. package/dist/chunks/ko-AZ8GrmXu.js +148 -0
  63. package/dist/chunks/ko-AZ8GrmXu.js.map +1 -0
  64. package/dist/chunks/ko-BKdzk0jX.js +2 -0
  65. package/dist/chunks/ko-BKdzk0jX.js.map +1 -0
  66. package/dist/chunks/nl-Bek7IiHL.js +2 -0
  67. package/dist/chunks/nl-Bek7IiHL.js.map +1 -0
  68. package/dist/chunks/nl-sF6ms5FU.js +144 -0
  69. package/dist/chunks/nl-sF6ms5FU.js.map +1 -0
  70. package/dist/chunks/no-BztcQKh8.js +2 -0
  71. package/dist/chunks/no-BztcQKh8.js.map +1 -0
  72. package/dist/chunks/no-DGf5PuW5.js +125 -0
  73. package/dist/chunks/no-DGf5PuW5.js.map +1 -0
  74. package/dist/chunks/pl-CMF2KerQ.js +2 -0
  75. package/dist/chunks/pl-CMF2KerQ.js.map +1 -0
  76. package/dist/chunks/pl-Dd-Ze6wn.js +125 -0
  77. package/dist/chunks/pl-Dd-Ze6wn.js.map +1 -0
  78. package/dist/chunks/pt-BL9X8Du2.js +144 -0
  79. package/dist/chunks/pt-BL9X8Du2.js.map +1 -0
  80. package/dist/chunks/pt-DF9cd_iW.js +2 -0
  81. package/dist/chunks/pt-DF9cd_iW.js.map +1 -0
  82. package/dist/chunks/ro-CGYmtR8q.js +125 -0
  83. package/dist/chunks/ro-CGYmtR8q.js.map +1 -0
  84. package/dist/chunks/ro-DpPc1UhJ.js +2 -0
  85. package/dist/chunks/ro-DpPc1UhJ.js.map +1 -0
  86. package/dist/chunks/ru-gt3-clOi.js +2 -0
  87. package/dist/chunks/ru-gt3-clOi.js.map +1 -0
  88. package/dist/chunks/ru-oPoQtUxk.js +147 -0
  89. package/dist/chunks/ru-oPoQtUxk.js.map +1 -0
  90. package/dist/chunks/sv-Cg7O9Uh3.js +2 -0
  91. package/dist/chunks/sv-Cg7O9Uh3.js.map +1 -0
  92. package/dist/chunks/sv-kXHP1Ct3.js +125 -0
  93. package/dist/chunks/sv-kXHP1Ct3.js.map +1 -0
  94. package/dist/chunks/th-DMcmb36d.js +129 -0
  95. package/dist/chunks/th-DMcmb36d.js.map +1 -0
  96. package/dist/chunks/th-pvtT9u-U.js +2 -0
  97. package/dist/chunks/th-pvtT9u-U.js.map +1 -0
  98. package/dist/chunks/tr-gAn3KCul.js +2 -0
  99. package/dist/chunks/tr-gAn3KCul.js.map +1 -0
  100. package/dist/chunks/tr-zjLbddlL.js +125 -0
  101. package/dist/chunks/tr-zjLbddlL.js.map +1 -0
  102. package/dist/chunks/uk-BYSiM14V.js +147 -0
  103. package/dist/chunks/uk-BYSiM14V.js.map +1 -0
  104. package/dist/chunks/uk-HIaOETe4.js +2 -0
  105. package/dist/chunks/uk-HIaOETe4.js.map +1 -0
  106. package/dist/chunks/vi-B7DVCjxx.js +2 -0
  107. package/dist/chunks/vi-B7DVCjxx.js.map +1 -0
  108. package/dist/chunks/vi-FbVRwy9D.js +125 -0
  109. package/dist/chunks/vi-FbVRwy9D.js.map +1 -0
  110. package/dist/chunks/zh-007yK7rl.js +2 -0
  111. package/dist/chunks/zh-007yK7rl.js.map +1 -0
  112. package/dist/chunks/zh-Cv0Yw4qR.js +148 -0
  113. package/dist/chunks/zh-Cv0Yw4qR.js.map +1 -0
  114. package/dist/core.cjs +1 -1
  115. package/dist/core.cjs.map +1 -1
  116. package/dist/core.d.ts +260 -26
  117. package/dist/core.js +505 -338
  118. package/dist/core.js.map +1 -1
  119. package/dist/index.cjs +1 -1
  120. package/dist/index.d.ts +411 -45
  121. package/dist/index.js +14 -10
  122. package/dist/ui.cjs +1 -1
  123. package/dist/ui.d.ts +376 -44
  124. package/dist/ui.js +1 -1
  125. package/package.json +32 -31
  126. package/dist/chunks/PaywallUI-CRTEPjJm.js +0 -2229
  127. package/dist/chunks/PaywallUI-CRTEPjJm.js.map +0 -1
  128. package/dist/chunks/PaywallUI-CbbcfXXZ.js +0 -26
  129. package/dist/chunks/PaywallUI-CbbcfXXZ.js.map +0 -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. Embeds into Chrome
4
- extensions and websites via npm / CDN, with no iframe and no remote code.
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
- Status: **alpha, WIP**. See [TODO.md](../TODO.md).
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/Paddle/Chargebee),
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
- ## Not in this version (alpha)
102
-
103
- - Auth layer (Google / Apple / Email) — coming after the hybrid beta.
104
- - Timer-based trials, A/B variants, localization.
105
- - Framework adapters (`@monetize/react`).
106
- - Tests.
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).