@extenshi/pay 0.8.0 → 0.11.0
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 +134 -19
- package/dist/api/mock.d.ts +4 -0
- package/dist/api/mock.d.ts.map +1 -1
- package/dist/api/pay-api.d.ts +9 -4
- package/dist/api/pay-api.d.ts.map +1 -1
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/extenshi-pay.d.ts +60 -5
- package/dist/core/extenshi-pay.d.ts.map +1 -1
- package/dist/core/index.d.ts +3 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/storage.d.ts +6 -0
- package/dist/core/storage.d.ts.map +1 -1
- package/dist/core.d.mts +280 -27
- package/dist/core.d.ts +280 -27
- package/dist/core.js +566 -44
- package/dist/core.js.map +1 -1
- package/dist/core.mjs +562 -45
- package/dist/core.mjs.map +1 -1
- package/dist/extenshi-pay-lite.js +555 -44
- package/dist/extenshi-pay-lite.js.map +1 -1
- package/dist/extenshi-pay-lite.min.js +3 -3
- package/dist/extenshi-pay-lite.min.js.map +1 -1
- package/dist/extenshi-pay-lite.mjs +555 -44
- package/dist/extenshi-pay-lite.mjs.map +1 -1
- package/dist/extenshi-pay.cjs.js +823 -69
- package/dist/extenshi-pay.cjs.js.map +1 -1
- package/dist/extenshi-pay.d.ts +11 -1
- package/dist/extenshi-pay.d.ts.map +1 -1
- package/dist/extenshi-pay.js +823 -69
- package/dist/extenshi-pay.js.map +1 -1
- package/dist/extenshi-pay.min.js +3 -3
- package/dist/extenshi-pay.min.js.map +1 -1
- package/dist/extenshi-pay.min.mjs +3 -3
- package/dist/extenshi-pay.min.mjs.map +1 -1
- package/dist/extenshi-pay.mjs +819 -70
- package/dist/extenshi-pay.mjs.map +1 -1
- package/dist/index.d.mts +305 -27
- package/dist/index.d.ts +305 -27
- package/dist/lite.d.mts +224 -14
- package/dist/lite.d.ts +224 -14
- package/dist/lite.d.ts.map +1 -1
- package/dist/payment/cloud-backup.d.ts +35 -0
- package/dist/payment/cloud-backup.d.ts.map +1 -0
- package/dist/payment/entitlement.d.ts +21 -5
- package/dist/payment/entitlement.d.ts.map +1 -1
- package/dist/payment/recovery.d.ts +4 -2
- package/dist/payment/recovery.d.ts.map +1 -1
- package/dist/payment/signature.d.ts +29 -3
- package/dist/payment/signature.d.ts.map +1 -1
- package/dist/payment/trial.d.ts +55 -0
- package/dist/payment/trial.d.ts.map +1 -0
- package/dist/paywall/i18n.d.ts +3 -0
- package/dist/paywall/i18n.d.ts.map +1 -1
- package/dist/paywall/icon.d.ts +18 -0
- package/dist/paywall/icon.d.ts.map +1 -0
- package/dist/paywall/renderer.d.ts +15 -0
- package/dist/paywall/renderer.d.ts.map +1 -1
- package/dist/paywall.d.mts +27 -1
- package/dist/paywall.d.ts +27 -1
- package/dist/paywall.js +131 -25
- package/dist/paywall.js.map +1 -1
- package/dist/paywall.mjs +131 -25
- package/dist/paywall.mjs.map +1 -1
- package/dist/types/config.d.ts +27 -1
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/contract.d.ts +35 -0
- package/dist/types/contract.d.ts.map +1 -1
- package/dist/types/entitlement.d.ts +37 -1
- package/dist/types/entitlement.d.ts.map +1 -1
- package/dist/types/events.d.ts +5 -1
- package/dist/types/events.d.ts.map +1 -1
- package/dist/types/paywall.d.ts +22 -1
- package/dist/types/paywall.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.d.ts.map +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -64,13 +64,24 @@ responses never unlock features outside explicit `mock: true` mode. A missing ke
|
|
|
64
64
|
or unsupported WebCrypto Ed25519 implementation reports `VERIFICATION_UNAVAILABLE`
|
|
65
65
|
through `onError`; initialization still resolves with access locked.
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
67
|
+
Which key verifies a license, in order:
|
|
68
|
+
|
|
69
|
+
1. the key the server returned in this browser session;
|
|
70
|
+
2. `entitlementPublicKey` from your configuration, when you bundle one;
|
|
71
|
+
3. without a bundled key, the server key the SDK saved in `chrome.storage.local`
|
|
72
|
+
next to the license.
|
|
73
|
+
|
|
74
|
+
After a restart with no network, 2 or 3 verifies the cached license until
|
|
75
|
+
`offlineUntil`. They differ in what a user who edits extension storage can do. A
|
|
76
|
+
bundled key is never replaced by one from storage, so an edited license is refused.
|
|
77
|
+
A saved key sits in the same storage as the license: with the license API
|
|
78
|
+
unreachable, a user who rewrites both gets paid access until the SDK next reaches
|
|
79
|
+
the server, which then drops the license. Bundle the key if that matters to you.
|
|
80
|
+
|
|
81
|
+
When the server's signing key is replaced, no known key verifies the new license.
|
|
82
|
+
The SDK then asks the server for its current key once and accepts a license that
|
|
83
|
+
key verifies, also when an older key is bundled. With an outdated bundled key each
|
|
84
|
+
restart needs the network, until you ship the new key.
|
|
74
85
|
|
|
75
86
|
Each signed envelope is bound to its application publishable key and installation.
|
|
76
87
|
Old caches without signed application scope require one online refresh on upgrade.
|
|
@@ -85,6 +96,26 @@ deadline for extension timers. The SDK also emits changes at license expiry whil
|
|
|
85
96
|
its context is alive. Signed issuance permits up to five minutes of server/client
|
|
86
97
|
clock skew; the offline allowance remains bounded by both signed issuance and local
|
|
87
98
|
fetch time. Suspended service workers must check again when they resume.
|
|
99
|
+
|
|
100
|
+
The 48 hours are the allowance of a license that names none. A license may carry a
|
|
101
|
+
signed `offlineSeconds` (set by the server per kind of purchase), which the SDK
|
|
102
|
+
uses instead, up to 366 days.
|
|
103
|
+
|
|
104
|
+
`clockSkew` on the entitlement is set when the device clock differed from the
|
|
105
|
+
server's by more than five minutes at the last license check:
|
|
106
|
+
`{ direction: 'ahead' | 'behind', ms }`. A clock ahead by more than the allowance
|
|
107
|
+
makes a license that was just checked read as due for another check, and a clock
|
|
108
|
+
behind makes the server's license look dated in the future, which the SDK refuses.
|
|
109
|
+
In both cases the device is online and access is paused, so tell the user what to fix:
|
|
110
|
+
|
|
111
|
+
```ts
|
|
112
|
+
const license = await pay.getEntitlement()
|
|
113
|
+
if (license.clockSkew && !license.features.length) {
|
|
114
|
+
show('Check the date and time on this device.')
|
|
115
|
+
} else if (license.requiresOnlineCheck) {
|
|
116
|
+
show('Connect to the internet to confirm your license.')
|
|
117
|
+
}
|
|
118
|
+
```
|
|
88
119
|
Mock mode is exempt from signature and offline limits.
|
|
89
120
|
|
|
90
121
|
The browser must provide Ed25519 in `crypto.subtle` in a secure context. Test your
|
|
@@ -101,13 +132,54 @@ await pay.showPaywall({
|
|
|
101
132
|
mode: 'modal', // 'modal' | 'inline' | 'sidebar' | 'fullscreen' | 'minimal'
|
|
102
133
|
sku: 'pro', // which offer to feature (default: first)
|
|
103
134
|
title: 'Go Pro',
|
|
104
|
-
|
|
135
|
+
description: 'Every export format in one plan.', // default: the offer's description
|
|
136
|
+
features: ['Unlimited exports', 'Sync'], // bullet points (modal: up to 6, minimal: up to 3); omit for no feature list
|
|
137
|
+
icon: 'icons/icon128.png', // default: the largest manifest icon; false keeps the glyph
|
|
105
138
|
theme: { mode: 'auto', primaryColor: '#0ea5e9' },
|
|
106
139
|
container: document.querySelector('#upsell'), // for inline mode
|
|
107
140
|
})
|
|
108
141
|
```
|
|
109
142
|
|
|
110
|
-
|
|
143
|
+
The offer's description is shown next to the price, once: when the header falls back to it, the price card leaves it out. `icon` takes a path inside the extension or a `data:image/` URL; remote URLs are ignored. On the extension's own pages the largest `manifest.icons` entry is the default; content scripts keep the template's glyph unless given a `data:image/` URL, since package files load on a site only through `web_accessible_resources`. `primaryColor` also sets the tints and shades (via `color-mix()`) the price card and links use.
|
|
144
|
+
|
|
145
|
+
Templates come from `@extenshi/paywall-templates` and are inlined at build time. The paywall, the license dialog and the billing-profile picker are translated into English, Spanish, Brazilian Portuguese, French, German, Italian, Russian, Japanese, Korean, Simplified Chinese and Arabic (right to left); the language follows `locale`, which defaults to the browser UI language. Any string can still be overridden per call (`strings: { upgrade: 'Kaufen' }`). Offer titles and descriptions come from the server in the buyer's language when you translated them in dojo (Monetization → Languages) or with `set_pay_offer_translations`. An offer's `features` are entitlement keys (`hasFeature('full')`, `offer.features.includes('full')`): they are never translated and never shown on the paywall. Its bullet points come only from the `features` option, so pass them from your own `_locales`: `showPaywall({ features: [chrome.i18n.getMessage('paywallSync')] })`. Without that option the paywall has no feature list. Prices are formatted with `Intl.NumberFormat` in the user's locale.
|
|
146
|
+
|
|
147
|
+
### Free trial
|
|
148
|
+
|
|
149
|
+
Set the trial length on the Pay application (Dojo Payments → Free trial, `set_pay_trial`, or
|
|
150
|
+
`trialDays` on `create_pay_app`). The server starts one clock per installation at its first
|
|
151
|
+
license read and signs `{ startedAt, endsAt }` into the license, so the extension stores no start
|
|
152
|
+
date of its own and switching plans never restarts it. Requires a backend with trial support
|
|
153
|
+
(catalog-bff, November 2026); an older one sends no trial and `getTrial()` returns `null`.
|
|
154
|
+
|
|
155
|
+
```ts
|
|
156
|
+
const trial = await pay.getTrial() // { active, startedAt, endsAt, daysLeft, requiresOnlineCheck } | null
|
|
157
|
+
const unlocked = (await pay.hasFeature('full')) || trial?.active === true
|
|
158
|
+
|
|
159
|
+
pay.on('trial:ending', (t) => setBadge(`${t.daysLeft}d`)) // trialEndingDays before the end (default 2)
|
|
160
|
+
pay.on('trial:ended', () => pay.showTrialEnded({ feedbackFormUrl: 'https://feedback.extenshi.io/f/<code>' }))
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
- `getTrial()` reads the verified license only, so it answers offline from the cache. Like paid
|
|
164
|
+
access, `active` needs a license check within 48 hours (`requiresOnlineCheck` says when one is
|
|
165
|
+
due), and the signed issue time is a floor, so turning the clock back does not reopen an ended
|
|
166
|
+
trial. `isPaid()` and `hasFeature()` stay purchase-only.
|
|
167
|
+
- `trial:ending` and `trial:ended` (the `trialEnding` / `trialEnded` of the spec, named like the
|
|
168
|
+
other `ns:verb` events) fire once per installation and trial; the marker is kept in the SDK's
|
|
169
|
+
storage, so a popup opened later does not repeat them. They do not fire while the user has
|
|
170
|
+
paid access. Render the current state from `getTrial()`.
|
|
171
|
+
- `showTrialEnded()` (full bundle) is the paywall with "Your free trial has ended", "tools are
|
|
172
|
+
paused, settings are kept", the plans and "Restore purchase" (when recovery is on), in the
|
|
173
|
+
user's language. The default text promises the settings are kept: pass `description` if your
|
|
174
|
+
extension does not keep them. `feedbackFormUrl` (HTTPS) adds a "Share feedback" button that
|
|
175
|
+
opens the form with `src=trial_end` and nothing that identifies the installation.
|
|
176
|
+
- The clock belongs to the installation's random `endUserRef`. **A reinstall starts a new
|
|
177
|
+
trial**, with or without browser sync: uninstalling clears the extension's `storage.sync` from
|
|
178
|
+
the account too, nothing else identifies the user, and the SDK does not fingerprint.
|
|
179
|
+
- The SDK keeps the start date (only the date, never the id) in `storage.sync` and sends it back
|
|
180
|
+
as `trialStartedHint`, so another device on the same synced browser account continues the same
|
|
181
|
+
trial; the server lets it move a start only earlier. `syncTrialStart: false` turns this off.
|
|
182
|
+
- `mockData: { trial: { days: 7 } }` previews a trial in mock mode.
|
|
111
183
|
|
|
112
184
|
### Restore a purchase in another browser
|
|
113
185
|
|
|
@@ -124,7 +196,34 @@ Run recovery in an extension page or background context. It creates a random cla
|
|
|
124
196
|
|
|
125
197
|
Recovery proofs use `storage.session`, which must retain its default trusted-context access. Do not expose this storage or recovery internals through a content-script message bridge. A suspended service worker can resume on `initialize()`. Restarting the browser, reloading/updating the extension, or using the memory fallback clears the proof: start a new recovery attempt. A custom `recoveryStorage` adapter must provide equivalent isolation. `restorePurchase({ signal, timeoutMs, openUrl })` supports cancellation, a shorter wait and a custom tab opener.
|
|
126
198
|
|
|
127
|
-
Only purchases indexed from matching completed Extenshi Pay checkouts can currently be recovered. Existing purchases require a separately reviewed backfill. This restores license access; it does not sign the user into Supabase
|
|
199
|
+
Only purchases indexed from matching completed Extenshi Pay checkouts can currently be recovered. Existing purchases require a separately reviewed backfill. This restores license access; it does not sign the user into Supabase. Settings come back only when the buyer turned on cloud backup (below). Recovered billing profiles remain separate and are available through `openCustomerPortal()`.
|
|
200
|
+
|
|
201
|
+
### Cloud backup of settings (0.11.0)
|
|
202
|
+
|
|
203
|
+
Uninstalling an extension clears its `storage.local` and `storage.sync`. A buyer who turns on cloud backup gets the settings kept by [`@extenshi/storage`](https://www.npmjs.com/package/@extenshi/storage) back after a reinstall or in another browser: "Restore purchase" and one code from the purchase email return the license and the settings.
|
|
204
|
+
|
|
205
|
+
```ts
|
|
206
|
+
import { ExtenshiStorage } from '@extenshi/storage'
|
|
207
|
+
|
|
208
|
+
const storage = ExtenshiStorage.create({
|
|
209
|
+
projectKey: EXTENSHI_CONFIG.PROJECT_ID,
|
|
210
|
+
namespace: 'reading-preferences',
|
|
211
|
+
schemaVersion: 1,
|
|
212
|
+
cloud: { getToken: () => pay.cloudBackupToken() },
|
|
213
|
+
})
|
|
214
|
+
|
|
215
|
+
// "Back up settings" (an extension page): the hosted page shows the storage disclosure first.
|
|
216
|
+
const result = await pay.enableCloudBackup()
|
|
217
|
+
if (result.state === 'complete') console.log(result.cloudBackup) // 'on' | 'no_consent' | 'license_required'
|
|
218
|
+
|
|
219
|
+
await pay.disableCloudBackup() // "Turn off" on this installation; the cloud copy stays
|
|
220
|
+
await pay.deleteCloudBackup() // "Delete cloud copy": all records, and backup off everywhere
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
- Off by default, for buyers only. `enableCloudBackup()` is `restorePurchase({ purpose: 'storage' })`; the server records the consent. A later plain `restorePurchase()` returns the token again when consent exists, so one code restores both.
|
|
224
|
+
- The token is stored in `storage.local` under `extenshi-pay:<publishableKey>:storageToken`. `cloudBackupToken()` rejects in a content script; do not forward the token through a message bridge. The SDK never logs it.
|
|
225
|
+
- `result.cloudBackup` is absent when the application does not offer backup (or the backend predates it). `license_required`: the license ended; the copy is kept for 90 days after the last license.
|
|
226
|
+
- `disableCloudBackup()` also forgets a token the server already revoked. `deleteCloudBackup()` needs the backup on here; it rejects with `httpStatus: 401` when the server no longer accepts the token.
|
|
128
227
|
|
|
129
228
|
### License details and author contact
|
|
130
229
|
|
|
@@ -192,18 +291,32 @@ const pay = new ExtenshiPay({
|
|
|
192
291
|
entitlements: [],
|
|
193
292
|
checkoutEnabled: true,
|
|
194
293
|
claimAfterPolls: 2,
|
|
294
|
+
seller: {
|
|
295
|
+
displayName: 'Reader Author',
|
|
296
|
+
supportUrl: 'https://example.com/support', // or a plain email address
|
|
297
|
+
termsUrl: 'https://example.com/terms',
|
|
298
|
+
refundPolicyUrl: 'https://example.com/terms#refunds',
|
|
299
|
+
},
|
|
195
300
|
},
|
|
196
301
|
})
|
|
197
302
|
```
|
|
198
303
|
|
|
199
304
|
No network, no backend: develop the paywall and the gating offline.
|
|
200
305
|
|
|
306
|
+
`seller` stands in for the seller details a live offer carries: the paywall and
|
|
307
|
+
the license panel show the name and the support, terms and refund links, and the
|
|
308
|
+
withdrawal-waiver text names the seller. Without it the mock paywall says
|
|
309
|
+
"License provider details are unavailable." and the waiver names the project;
|
|
310
|
+
`seller: null` also disables the purchase button, as a live offer without seller
|
|
311
|
+
details does. `withdrawalWaiver` (default: required, current version) previews
|
|
312
|
+
the waiver checkbox; `null` previews a seller outside the EEA/UK.
|
|
313
|
+
|
|
201
314
|
## Configuration
|
|
202
315
|
|
|
203
316
|
| Option | Default | Notes |
|
|
204
317
|
|---|---|---|
|
|
205
318
|
| `publishableKey` | — | required, `pk_ext_` + 32 hex |
|
|
206
|
-
| `entitlementPublicKey` | fetched from API | raw 32-byte Ed25519 public key in base64; bundle it
|
|
319
|
+
| `entitlementPublicKey` | fetched from API and saved | raw 32-byte Ed25519 public key in base64; bundle it so a key from storage is never used |
|
|
207
320
|
| `apiUrl` | `https://bff.extenshi.io` | |
|
|
208
321
|
| `cacheTtlMs` | `3600000` | entitlement cache TTL |
|
|
209
322
|
| `locale` | browser UI language (`chrome.i18n.getUILanguage()`) | the paywall language and price formatting; also sent to checkout, the billing portal and license recovery so the hosted pages and the recovery email use it. `null` opts out (English UI) |
|
|
@@ -211,24 +324,26 @@ No network, no backend: develop the paywall and the gating offline.
|
|
|
211
324
|
| `theme` | — | `mode`, `primaryColor`, `fontFamily`, `borderRadius`, `customCss` |
|
|
212
325
|
| `mock` / `mockData` | `false` | offline development |
|
|
213
326
|
| `onReady` / `onError` | — | callbacks; the same events are on `pay.on(...)` |
|
|
327
|
+
| `trialEndingDays` | `2` | days before the trial's end that `trial:ending` fires; `0` turns it off |
|
|
328
|
+
| `syncTrialStart` | `true` | keep the trial start date in `storage.sync` and send it back, so other devices on the same synced browser account share the trial |
|
|
214
329
|
|
|
215
|
-
Events: `ready`, `entitlement:changed`, `checkout:started`, `checkout:completed`, `checkout:canceled`, `checkout:expired`, `error`.
|
|
330
|
+
Events: `ready`, `entitlement:changed`, `checkout:started`, `checkout:completed`, `checkout:canceled`, `checkout:expired`, `trial:ending`, `trial:ended`, `error`.
|
|
216
331
|
|
|
217
332
|
## What leaves the extension
|
|
218
333
|
|
|
219
|
-
Normal payment calls send `publishableKey`, `endUserRef` (a random UUID), `sku` and `locale` (the language, also sent when recovery or the billing portal starts); checkout claims also send `sessionId`. Explicit recovery additionally sends a random session ID, a SHA-256 claim challenge and its installation-held secret (POST body). The checkout email and verification code are entered only on the hosted recovery page. Selecting a billing profile also sends its opaque `customerId`. No fingerprint or extension settings are collected by this SDK. Store privacy disclosures must cover installation/license verification and this optional recovery flow.
|
|
334
|
+
Normal payment calls send `publishableKey`, `endUserRef` (a random UUID), `sku` and `locale` (the language, also sent when recovery or the billing portal starts); checkout claims also send `sessionId`. Explicit recovery additionally sends a random session ID, a SHA-256 claim challenge and its installation-held secret (POST body). The checkout email and verification code are entered only on the hosted recovery page. Selecting a billing profile also sends its opaque `customerId`. No fingerprint or extension settings are collected by this SDK; with cloud backup on, `@extenshi/storage` sends the namespace's records to `/v1/storage` with the storage token, and this SDK sends the token when backup is turned off or deleted. When the application has a free trial, the server stores the time the `endUserRef` first read its license; the SDK keeps that date in `storage.sync` (synced by the browser across the user's devices) and sends it back as `trialStartedHint` with license checks, unless `syncTrialStart: false`. Store privacy disclosures must cover installation/license verification and this optional recovery flow.
|
|
220
335
|
|
|
221
336
|
## Bundle sizes (gzip)
|
|
222
337
|
|
|
223
|
-
Measured
|
|
338
|
+
Measured at 0.11.0 the way `scripts/pay-sdk-release-check.mjs` does (gzip bytes; ESM, before consumer tree shaking):
|
|
224
339
|
|
|
225
340
|
| Bundle | Size |
|
|
226
341
|
|---|---|
|
|
227
|
-
| Full `extenshi-pay.mjs` |
|
|
228
|
-
| Full minified `extenshi-pay.min.mjs` |
|
|
229
|
-
| Lite `extenshi-pay-lite.mjs` |
|
|
230
|
-
| Core `core.mjs` |
|
|
231
|
-
| Paywall `paywall.mjs` |
|
|
342
|
+
| Full `extenshi-pay.mjs` | 63,578 B |
|
|
343
|
+
| Full minified `extenshi-pay.min.mjs` | 45,459 B |
|
|
344
|
+
| Lite `extenshi-pay-lite.mjs` | 26,175 B |
|
|
345
|
+
| Core `core.mjs` | 27,195 B |
|
|
346
|
+
| Paywall `paywall.mjs` | 34,402 B |
|
|
232
347
|
|
|
233
348
|
About 13 KB of the full bundle is the compiled-in dictionary for ten languages (no remote strings, as store policies require). Lite and core render no UI and carry none of it.
|
|
234
349
|
|
package/dist/api/mock.d.ts
CHANGED
|
@@ -22,11 +22,15 @@ export declare class MockTransport implements Transport {
|
|
|
22
22
|
private readonly checkoutEnabled;
|
|
23
23
|
private readonly claimAfterPolls;
|
|
24
24
|
private readonly withdrawalWaiver;
|
|
25
|
+
private readonly seller;
|
|
26
|
+
private trial;
|
|
25
27
|
readonly sessions: Map<string, MockSession>;
|
|
26
28
|
constructor(data?: MockData);
|
|
27
29
|
call<T>(procedure: string, _kind: ProcedureKind, input: Record<string, unknown>): Promise<T>;
|
|
28
30
|
/** Test/dev helpers. */
|
|
29
31
|
setEntitlements(items: PayEntitlementItem[]): void;
|
|
32
|
+
/** Previews a server trial of `days` from `startedAt` (default now); `null` removes it. */
|
|
33
|
+
setTrial(days: number | null, startedAt?: string): void;
|
|
30
34
|
cancelSession(sessionId: string): void;
|
|
31
35
|
expireSession(sessionId: string): void;
|
|
32
36
|
private offerResponse;
|
package/dist/api/mock.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock.d.ts","sourceRoot":"","sources":["../../src/api/mock.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAIN,KAAK,kBAAkB,
|
|
1
|
+
{"version":3,"file":"mock.d.ts","sourceRoot":"","sources":["../../src/api/mock.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAIN,KAAK,kBAAkB,EAOvB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAA;AAEtE,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE9D,KAAK,YAAY,GAAG,MAAM,GAAG,UAAU,GAAG,UAAU,GAAG,SAAS,CAAA;AAEhE,UAAU,WAAW;IACpB,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,YAAY,CAAA;IACnB,+EAA+E;IAC/E,gBAAgB,EAAE,uBAAuB,GAAG,IAAI,CAAA;CAChD;AAYD,qBAAa,aAAc,YAAW,SAAS;IAC9C,OAAO,CAAC,YAAY,CAAsB;IAC1C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAe;IACtC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAQ;IACpC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAS;IACzC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAQ;IACxC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAA4B;IAC7D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAoC;IAC3D,OAAO,CAAC,KAAK,CAAiB;IAC9B,QAAQ,CAAC,QAAQ,2BAAiC;gBAEtC,IAAI,GAAE,QAAa;IAazB,IAAI,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAqBlG,wBAAwB;IACxB,eAAe,CAAC,KAAK,EAAE,kBAAkB,EAAE,GAAG,IAAI;IAIlD,2FAA2F;IAC3F,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,EAAE,SAAS,GAAE,MAAiC,GAAG,IAAI;IAQjF,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAKtC,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAKtC,OAAO,CAAC,aAAa;IAarB,OAAO,CAAC,cAAc;IAgBtB,OAAO,CAAC,KAAK;IAcb,OAAO,CAAC,KAAK;IAmBb,OAAO,CAAC,QAAQ;CAchB"}
|
package/dist/api/pay-api.d.ts
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
/** Typed wrapper over the SDK-facing `pay.*` procedures. Nothing else is ever called. */
|
|
2
|
-
import type { PayCheckoutClaim, PayCheckoutSession, PayOfferResponse, PayPortalResponse, PayRestoreClaimResponse, PayRestoreSessionResponse, SignedEntitlement } from '../types/contract.js';
|
|
2
|
+
import type { PayCheckoutClaim, PayCheckoutSession, PayOfferResponse, PayPortalResponse, PayRestoreClaimResponse, PayRestorePurpose, PayRestoreSessionResponse, SignedEntitlement } from '../types/contract.js';
|
|
3
3
|
import type { WithdrawalWaiverConsent } from '../types/entitlement.js';
|
|
4
4
|
import type { Transport } from './transport.js';
|
|
5
5
|
export declare class PayApi {
|
|
6
6
|
private readonly transport;
|
|
7
7
|
private readonly publishableKey;
|
|
8
8
|
constructor(transport: Transport, publishableKey: string);
|
|
9
|
-
/**
|
|
10
|
-
|
|
9
|
+
/**
|
|
10
|
+
* `locale` opens the hosted recovery page (and its email) in the user's language.
|
|
11
|
+
* `purpose` is sent only for `storage`: a plain restore keeps the request older
|
|
12
|
+
* BFFs know, and their non-strict zod input strips the key anyway.
|
|
13
|
+
*/
|
|
14
|
+
createRestoreSession(claimChallenge: string, locale?: string | null, purpose?: PayRestorePurpose): Promise<PayRestoreSessionResponse>;
|
|
11
15
|
claimRestoreSession(sessionId: string, claimSecret: string): Promise<PayRestoreClaimResponse>;
|
|
12
16
|
getOffer(locale?: string | null): Promise<PayOfferResponse>;
|
|
13
17
|
/**
|
|
@@ -17,7 +21,8 @@ export declare class PayApi {
|
|
|
17
21
|
*/
|
|
18
22
|
createCheckout(sku: string, endUserRef: string, locale?: string | null, withdrawalWaiver?: WithdrawalWaiverConsent): Promise<PayCheckoutSession>;
|
|
19
23
|
claimSession(sessionId: string, endUserRef: string): Promise<PayCheckoutClaim>;
|
|
20
|
-
|
|
24
|
+
/** `trialStartedHint`: the trial start kept in storage.sync; the server only lets it move a start earlier. */
|
|
25
|
+
getEntitlement(endUserRef: string, trialStartedHint?: string | null): Promise<SignedEntitlement>;
|
|
21
26
|
getPortalUrl(endUserRef: string, customerId?: string, locale?: string | null): Promise<PayPortalResponse>;
|
|
22
27
|
}
|
|
23
28
|
//# sourceMappingURL=pay-api.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pay-api.d.ts","sourceRoot":"","sources":["../../src/api/pay-api.ts"],"names":[],"mappings":"AAAA,yFAAyF;AAEzF,OAAO,KAAK,EACX,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,uBAAuB,EACvB,yBAAyB,EACzB,iBAAiB,EACjB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAA;AACtE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,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AC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAQ9E,8GAA8G;IAC9G,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAQhG,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,iBAAiB,CAAC;CAQzG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/core/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/core/config.ts"],"names":[],"mappings":"AACA,OAAO,EAIN,KAAK,iBAAiB,EAEtB,KAAK,cAAc,EACnB,MAAM,oBAAoB,CAAA;AAQ3B,6DAA6D;AAC7D,eAAO,MAAM,SAAS,QAAgC,CAAA;AAWtD,wBAAgB,aAAa,CAAC,KAAK,EAAE,iBAAiB,GAAG,cAAc,CAuEtE"}
|
|
@@ -4,8 +4,10 @@
|
|
|
4
4
|
* extends it with `getOffer()` / `showPaywall()`.
|
|
5
5
|
*
|
|
6
6
|
* Data that leaves the extension: `publishableKey`, `endUserRef`, `sku`,
|
|
7
|
-
* `locale
|
|
8
|
-
*
|
|
7
|
+
* `locale`, checkout session IDs and, with a server trial, the trial start date
|
|
8
|
+
* the server issued (`trialStartedHint`, kept in storage.sync). Explicit recovery also sends its session ID,
|
|
9
|
+
* challenge and claim secret (POST body). Email stays on the hosted page. With cloud backup, the
|
|
10
|
+
* storage token goes only to `/v1/storage` (as a bearer), never in a message to a content script.
|
|
9
11
|
*/
|
|
10
12
|
import { PayApi } from '../api/pay-api.js';
|
|
11
13
|
import { type Transport } from '../api/transport.js';
|
|
@@ -14,7 +16,7 @@ import { EntitlementManager } from '../payment/entitlement.js';
|
|
|
14
16
|
import { RecoveryManager } from '../payment/recovery.js';
|
|
15
17
|
import type { ExtenshiPayConfig, ResolvedConfig } from '../types/config.js';
|
|
16
18
|
import type { PayOfferResponse } from '../types/contract.js';
|
|
17
|
-
import type { CheckoutOptions, CheckoutResult, CustomerPortalOptions, Entitlement, GetEntitlementOptions, LicenseSummary, RequireFeatureOptions, RestoreOptions, RestoreResult } from '../types/entitlement.js';
|
|
19
|
+
import type { CheckoutOptions, CheckoutResult, CustomerPortalOptions, Entitlement, GetEntitlementOptions, LicenseSummary, RequireFeatureOptions, RestoreOptions, RestoreResult, TrialState } from '../types/entitlement.js';
|
|
18
20
|
import { ExtenshiPayError } from '../types/errors.js';
|
|
19
21
|
import type { ExtenshiPayEvents } from '../types/events.js';
|
|
20
22
|
import { EventEmitter, type Listener } from './event-emitter.js';
|
|
@@ -22,6 +24,8 @@ import { type StorageAdapter } from './storage.js';
|
|
|
22
24
|
/** Injection points for tests and unusual hosts. */
|
|
23
25
|
export interface ExtenshiPayDeps {
|
|
24
26
|
storage?: StorageAdapter;
|
|
27
|
+
/** Where the trial start is synced (default `storage.sync`); null turns syncing off. */
|
|
28
|
+
syncStorage?: StorageAdapter | null;
|
|
25
29
|
/** Trusted extension-only storage; never share this adapter with content scripts. */
|
|
26
30
|
recoveryStorage?: StorageAdapter;
|
|
27
31
|
transport?: Transport;
|
|
@@ -30,7 +34,7 @@ export interface ExtenshiPayDeps {
|
|
|
30
34
|
now?: () => number;
|
|
31
35
|
}
|
|
32
36
|
export declare class ExtenshiPayLite {
|
|
33
|
-
static readonly version = "0.
|
|
37
|
+
static readonly version = "0.11.0";
|
|
34
38
|
protected readonly config: ResolvedConfig;
|
|
35
39
|
protected readonly emitter: EventEmitter<ExtenshiPayEvents>;
|
|
36
40
|
protected readonly storage: StorageAdapter;
|
|
@@ -38,11 +42,21 @@ export declare class ExtenshiPayLite {
|
|
|
38
42
|
protected readonly entitlements: EntitlementManager;
|
|
39
43
|
protected readonly checkout: CheckoutManager;
|
|
40
44
|
protected readonly recovery: RecoveryManager;
|
|
45
|
+
private readonly backup;
|
|
46
|
+
/** `deps.openUrl`, for tabs the full SDK opens outside checkout and recovery. */
|
|
47
|
+
protected readonly openUrl: ((url: string) => void | Promise<void>) | undefined;
|
|
48
|
+
private readonly trial;
|
|
49
|
+
/** storage.sync for the trial start; null when off, in mock mode, or outside an extension. */
|
|
50
|
+
private readonly syncStorage;
|
|
41
51
|
private readonly now;
|
|
42
52
|
private endUserRef;
|
|
43
53
|
private endUserRefPromise;
|
|
44
54
|
private offer;
|
|
45
55
|
private offerInflight;
|
|
56
|
+
/** The signing key the server returned in this session; never one read from storage. */
|
|
57
|
+
private serverKey;
|
|
58
|
+
/** Trust order for license signatures; see payment/signature.ts. */
|
|
59
|
+
private readonly keys;
|
|
46
60
|
private readyPromise;
|
|
47
61
|
private destroyed;
|
|
48
62
|
constructor(config: ExtenshiPayConfig, deps?: ExtenshiPayDeps);
|
|
@@ -59,6 +73,13 @@ export declare class ExtenshiPayLite {
|
|
|
59
73
|
getEndUserRef(): Promise<string>;
|
|
60
74
|
getCachedEntitlement(): Entitlement | null;
|
|
61
75
|
getEntitlement(options?: GetEntitlementOptions): Promise<Entitlement>;
|
|
76
|
+
/**
|
|
77
|
+
* The free trial the application set on the server, from the verified license, or null when
|
|
78
|
+
* there is none (or the license could not be verified yet). Answers offline from the cached
|
|
79
|
+
* license; like paid access, `active` needs a license check within 48 hours. `isPaid()` and
|
|
80
|
+
* `hasFeature()` do not include the trial: grant trial access with `(await getTrial())?.active`.
|
|
81
|
+
*/
|
|
82
|
+
getTrial(options?: GetEntitlementOptions): Promise<TrialState | null>;
|
|
62
83
|
/** True when any active/grace entitlement exists, or the given `sku` is active/grace. */
|
|
63
84
|
isPaid(sku?: string): Promise<boolean>;
|
|
64
85
|
hasFeature(feature: string): Promise<boolean>;
|
|
@@ -90,6 +111,23 @@ export declare class ExtenshiPayLite {
|
|
|
90
111
|
openCheckout(sku: string, options?: CheckoutOptions): Promise<CheckoutResult>;
|
|
91
112
|
/** Opens email verification on the hosted page. No email is collected inside the extension. */
|
|
92
113
|
restorePurchase(options?: RestoreOptions): Promise<RestoreResult>;
|
|
114
|
+
/**
|
|
115
|
+
* Turns on the cloud copy of the extension's settings (`@extenshi/storage`): the
|
|
116
|
+
* hosted restore page shows the storage disclosure and the buyer confirms with
|
|
117
|
+
* the code from the purchase email. `cloudBackup` in the result says whether it is
|
|
118
|
+
* on. Buyers only; consent is recorded by the server.
|
|
119
|
+
*/
|
|
120
|
+
enableCloudBackup(options?: Omit<RestoreOptions, 'purpose'>): Promise<RestoreResult>;
|
|
121
|
+
/**
|
|
122
|
+
* The storage token for `ExtenshiStorage.create({ cloud: { getToken } })`, or null
|
|
123
|
+
* while cloud backup is off on this installation. Extension pages and background
|
|
124
|
+
* only: it rejects in a content script, and must never be sent to one.
|
|
125
|
+
*/
|
|
126
|
+
cloudBackupToken(): Promise<string | null>;
|
|
127
|
+
/** Turns cloud backup off on this installation: revokes its token. The cloud copy stays. */
|
|
128
|
+
disableCloudBackup(): Promise<void>;
|
|
129
|
+
/** Deletes the buyer's cloud copy and turns cloud backup off on every installation. */
|
|
130
|
+
deleteCloudBackup(): Promise<void>;
|
|
93
131
|
/** Read-only license view. Entitlements retain cache/signature/offline semantics. */
|
|
94
132
|
getLicenseSummary(options?: GetEntitlementOptions): Promise<LicenseSummary>;
|
|
95
133
|
/** Opens the provider's self-service portal; resolves null when the provider has none. */
|
|
@@ -103,7 +141,24 @@ export declare class ExtenshiPayLite {
|
|
|
103
141
|
destroy(): void;
|
|
104
142
|
/** Offer + signing key. Public in the full SDK (`getOffer`), internal here. */
|
|
105
143
|
protected fetchOffer(force?: boolean): Promise<PayOfferResponse>;
|
|
106
|
-
private
|
|
144
|
+
private get serverKeyStorageKey();
|
|
145
|
+
private readSavedServerKey;
|
|
146
|
+
/**
|
|
147
|
+
* Keeps the server's key next to the license cache so a restart with no network can verify it.
|
|
148
|
+
* Not with a bundled key: that one already covers the restart, and storage stays untrusted.
|
|
149
|
+
*/
|
|
150
|
+
private rememberServerKey;
|
|
151
|
+
/**
|
|
152
|
+
* A license verified with the saved key alone is checked against the server once per start:
|
|
153
|
+
* when the server's key differs (rotation, or an edited storage) the license is fetched again,
|
|
154
|
+
* and dropped if it does not verify. Offline, the saved key stands until `offlineUntil`.
|
|
155
|
+
*/
|
|
156
|
+
private confirmSavedServerKey;
|
|
157
|
+
private get trialStartKey();
|
|
158
|
+
/** The synced trial start, or null (none, malformed, or storage.sync unavailable). */
|
|
159
|
+
private readTrialStartHint;
|
|
160
|
+
/** Syncs the verified trial start, keeping the earliest one seen. Never the installation id. */
|
|
161
|
+
private rememberTrialStart;
|
|
107
162
|
protected reportError(error: unknown): ExtenshiPayError;
|
|
108
163
|
}
|
|
109
164
|
//# sourceMappingURL=extenshi-pay.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extenshi-pay.d.ts","sourceRoot":"","sources":["../../src/core/extenshi-pay.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"extenshi-pay.d.ts","sourceRoot":"","sources":["../../src/core/extenshi-pay.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAC1C,OAAO,EAAiB,KAAK,SAAS,EAAE,MAAM,qBAAqB,CAAA;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAExD,OAAO,EAAE,kBAAkB,EAAqB,MAAM,2BAA2B,CAAA;AAEjF,OAAO,EAAyB,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAI/E,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAC3E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAE5D,OAAO,KAAK,EACX,eAAe,EACf,cAAc,EACd,qBAAq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AQ,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI;IAIrG,IAAI,CAAC,CAAC,SAAS,MAAM,iBAAiB,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI;IAIvG,GAAG,CAAC,CAAC,SAAS,MAAM,iBAAiB,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI;IAIhG,mBAAmB,CAAC,QAAQ,EAAE,QAAQ,CAAC,WAAW,CAAC,GAAG,MAAM,IAAI;IAI1D,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAKjC,oDAAoD;IACpD,OAAO,IAAI,IAAI;IAQf,+EAA+E;IAC/E,SAAS,CAAC,UAAU,CAAC,KAAK,UAAQ,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAmB9D,OAAO,KAAK,mBAAmB,GAE9B;YAEa,kBAAkB;IAShC;;;OAGG;YACW,iBAAiB;IAW/B;;;;OAIG;YACW,qBAAqB;IAgBnC,OAAO,KAAK,aAAa,GAExB;IAED,sFAAsF;YACxE,kBAAkB;IAUhC,gGAAgG;YAClF,kBAAkB;IAYhC,SAAS,CAAC,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,gBAAgB;CAMvD"}
|
package/dist/core/index.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ export type { HttpTransportOptions, ProcedureKind, Transport } from '../api/tran
|
|
|
4
4
|
export { HttpTransport, TRPC_PATH, trpcErrorToPayError } from '../api/transport.js';
|
|
5
5
|
export type { CheckoutManagerOptions } from '../payment/checkout.js';
|
|
6
6
|
export { CHECKOUT_POLL_INTERVAL_MS, CHECKOUT_TIMEOUT_MS, CheckoutManager, openInNewTab, } from '../payment/checkout.js';
|
|
7
|
+
export type { CloudBackupOptions } from '../payment/cloud-backup.js';
|
|
8
|
+
export { CloudBackup } from '../payment/cloud-backup.js';
|
|
7
9
|
export type { EntitlementManagerOptions } from '../payment/entitlement.js';
|
|
8
10
|
export { EntitlementManager, MAX_REFRESH_BACKOFF_MS, MIN_REFRESH_INTERVAL_MS, } from '../payment/entitlement.js';
|
|
9
11
|
export { applyLocalExpiry, checkFeatures, collectFeatures, EMPTY_ENTITLEMENT, hasFeature, isEntitled, isLive, } from '../payment/features.js';
|
|
@@ -21,5 +23,5 @@ export type { ExtenshiPayDeps } from './extenshi-pay.js';
|
|
|
21
23
|
export { ExtenshiPayLite } from './extenshi-pay.js';
|
|
22
24
|
export { END_USER_REF_STORAGE_KEY, getOrCreateEndUserRef, mintEndUserRef } from './identity.js';
|
|
23
25
|
export type { StorageAdapter } from './storage.js';
|
|
24
|
-
export { createStorage, ExtensionStorage, LocalStorageAdapter, MemoryStorage } from './storage.js';
|
|
26
|
+
export { createStorage, createSyncStorage, ExtensionStorage, LocalStorageAdapter, MemoryStorage, } from './storage.js';
|
|
25
27
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/core/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAC1C,YAAY,EAAE,oBAAoB,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AACzF,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AACnF,YAAY,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;AACpE,OAAO,EACN,yBAAyB,EACzB,mBAAmB,EACnB,eAAe,EACf,YAAY,GACZ,MAAM,wBAAwB,CAAA;AAC/B,YAAY,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAA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OAAO,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAC/F,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,EACN,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,mBAAmB,EACnB,aAAa,GACb,MAAM,cAAc,CAAA"}
|
package/dist/core/storage.d.ts
CHANGED
|
@@ -37,6 +37,12 @@ export declare class MemoryStorage implements StorageAdapter {
|
|
|
37
37
|
set(key: string, value: unknown): Promise<void>;
|
|
38
38
|
remove(key: string): Promise<void>;
|
|
39
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* The browser's synced storage (`storage.sync`), or null outside an extension. The SDK keeps
|
|
42
|
+
* only the trial start there (never `endUserRef`), so devices on one synced account share the
|
|
43
|
+
* trial. Uninstalling clears it from the account, so it does not survive a reinstall.
|
|
44
|
+
*/
|
|
45
|
+
export declare function createSyncStorage(): StorageAdapter | null;
|
|
40
46
|
export declare function createStorage(): StorageAdapter;
|
|
41
47
|
export {};
|
|
42
48
|
//# sourceMappingURL=storage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/core/storage.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,WAAW,cAAc;IAC9B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IAClC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC/C,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAClC;AAED,KAAK,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAEpC,UAAU,WAAW;IACpB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,CAAC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