@monetize.software/sdk-extension 3.0.0-alpha.7 → 3.0.0-alpha.8
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 +18 -20
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -23,20 +23,12 @@ content script (per tab) ──port──▶ service worker ──port──▶
|
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
- **content-script:** UI + RemoteBillingClient (proxy over a port into offscreen).
|
|
26
|
-
- **service worker:** content↔offscreen router
|
|
27
|
-
(
|
|
26
|
+
- **service worker:** content↔offscreen router. OAuth uses a popup window opened
|
|
27
|
+
against your `apiOrigin` (custom_domain) — `chrome.identity` is **not** used.
|
|
28
28
|
- **offscreen:** the real SDK state, survives tab closes, the sole coordination
|
|
29
29
|
point for auth refresh / trial counter / analytics batching.
|
|
30
30
|
|
|
31
|
-
##
|
|
32
|
-
|
|
33
|
-
Phase 0 — skeleton: package.json, vite multi-entry, wire-protocol types,
|
|
34
|
-
stubs for content/offscreen/sw and a demo-extension manifest. Actual routing
|
|
35
|
-
and `RemoteBillingClient` come in the next phases.
|
|
36
|
-
|
|
37
|
-
See TODO in the repo and `src/shared/protocol.ts` for the message contract.
|
|
38
|
-
|
|
39
|
-
## Usage (target shape, when complete)
|
|
31
|
+
## Usage
|
|
40
32
|
|
|
41
33
|
**In the extension:**
|
|
42
34
|
|
|
@@ -69,18 +61,24 @@ permissions to match its own UX. Minimum for the SDK to work:
|
|
|
69
61
|
```json
|
|
70
62
|
{
|
|
71
63
|
"permissions": ["offscreen", "storage"],
|
|
72
|
-
"host_permissions": ["https://
|
|
64
|
+
"host_permissions": ["https://your-paywall-domain.com/*"],
|
|
73
65
|
"background": { "service_worker": "sw.js", "type": "module" }
|
|
74
66
|
}
|
|
75
67
|
```
|
|
76
68
|
|
|
77
|
-
|
|
69
|
+
`host_permissions` must list **your `apiOrigin`** — the `custom_domain` configured
|
|
70
|
+
for your paywall in the platform (the same value you pass to `new PaywallUI({ apiOrigin })`).
|
|
71
|
+
This is the only origin the SDK calls from offscreen / SW / content-script (bootstrap,
|
|
72
|
+
checkout, billing, auth). There is no `api.monetize.software` — every customer ships
|
|
73
|
+
their own custom domain.
|
|
74
|
+
|
|
75
|
+
`web_accessible_resources` for `offscreen.html` is **not required** — the document
|
|
76
|
+
is created by the service worker via `chrome.offscreen.createDocument`, a Chrome API
|
|
77
|
+
that doesn't need WAR. Listing it adds attack surface (any site could `<iframe>` your
|
|
78
|
+
offscreen, plus it fingerprints your extension ID).
|
|
78
79
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
document is created by the service worker via `chrome.offscreen.createDocument`,
|
|
82
|
-
that's a Chrome API and doesn't need WAR. Listing it adds attack surface (any
|
|
83
|
-
site could `<iframe>` your offscreen, plus it fingerprints your extension ID).
|
|
80
|
+
The SDK does **not** use `chrome.identity` — OAuth runs via a popup window opened
|
|
81
|
+
against your `apiOrigin`, so no `"identity"` permission is needed.
|
|
84
82
|
|
|
85
83
|
### `host_permissions` — what to pick
|
|
86
84
|
|
|
@@ -91,8 +89,8 @@ injected into (together with `content_scripts.matches`).
|
|
|
91
89
|
| Scenario | Recommendation |
|
|
92
90
|
|---|---|
|
|
93
91
|
| **Host extension already needs `<all_urls>`** (recorder, all-sites tool, assistant) | Keep `<all_urls>`. SDK works as-is. **Risk:** Chrome Web Store review for `<all_urls>` is a manual audit and takes longer; AV vendors (Avast/Kaspersky/etc.) are more likely to flag such extensions as PUA. That's the price of broad injection — it's a property of your use case, not an SDK risk. |
|
|
94
|
-
| **Host extension only talks to your backend and gates its own features** (popup tool, side-panel app) | Do NOT request `<all_urls>`. Your `apiOrigin` is enough: `["https://
|
|
95
|
-
| **Hybrid** — popup tool, but content-script needed on a narrow list of domains | Constrain both `host_permissions` and `content_scripts.matches` to those domains: `["https://*.your-target.com/*", "https://
|
|
92
|
+
| **Host extension only talks to your backend and gates its own features** (popup tool, side-panel app) | Do NOT request `<all_urls>`. Your `apiOrigin` (custom_domain) is enough: `["https://your-paywall-domain.com/*"]`. No content-script injection on every site needed. |
|
|
93
|
+
| **Hybrid** — popup tool, but content-script needed on a narrow list of domains | Constrain both `host_permissions` and `content_scripts.matches` to those domains: `["https://*.your-target.com/*", "https://your-paywall-domain.com/*"]`. |
|
|
96
94
|
|
|
97
95
|
The main signal to CWS/AV: the narrower `host_permissions`, the less suspicion.
|
|
98
96
|
Keep `<all_urls>` only when it's genuinely required for your UX, and be ready to
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@monetize.software/sdk-extension",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.8",
|
|
4
4
|
"description": "Monetize SDK for Chrome extensions — single source of truth via offscreen document, drop-in compatible with @monetize.software/sdk public API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"preact": "^10.24.0"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"@monetize.software/sdk": "3.0.0-alpha.
|
|
43
|
+
"@monetize.software/sdk": "3.0.0-alpha.7"
|
|
44
44
|
},
|
|
45
45
|
"peerDependenciesMeta": {
|
|
46
46
|
"@monetize.software/sdk": {
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"vite": "^6.0.5",
|
|
59
59
|
"vite-plugin-dts": "^4.3.0",
|
|
60
60
|
"vitest": "^2.1.8",
|
|
61
|
-
"@monetize.software/sdk": "3.0.0-alpha.
|
|
61
|
+
"@monetize.software/sdk": "3.0.0-alpha.7"
|
|
62
62
|
},
|
|
63
63
|
"scripts": {
|
|
64
64
|
"dev": "vite",
|