@extenshi/pay 0.9.0 → 0.12.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 +138 -17
- 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 +271 -26
- package/dist/core.d.ts +271 -26
- package/dist/core.js +589 -49
- package/dist/core.js.map +1 -1
- package/dist/core.mjs +584 -50
- package/dist/core.mjs.map +1 -1
- package/dist/extenshi-pay-lite.js +577 -49
- 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 +577 -49
- package/dist/extenshi-pay-lite.mjs.map +1 -1
- package/dist/extenshi-pay.cjs.js +694 -61
- 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 +694 -61
- 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 +689 -62
- package/dist/extenshi-pay.mjs.map +1 -1
- package/dist/index.d.mts +288 -26
- package/dist/index.d.ts +288 -26
- package/dist/lite.d.mts +214 -13
- package/dist/lite.d.ts +214 -13
- 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/renderer.d.ts +7 -0
- package/dist/paywall/renderer.d.ts.map +1 -1
- package/dist/paywall.d.mts +7 -0
- package/dist/paywall.d.ts +7 -0
- package/dist/paywall.js +54 -14
- package/dist/paywall.js.map +1 -1
- package/dist/paywall.mjs +54 -14
- 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 +36 -0
- package/dist/types/contract.d.ts.map +1 -1
- package/dist/types/entitlement.d.ts +39 -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 +10 -0
- 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
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
Payments for browser extensions, bundled into the extension itself.
|
|
6
6
|
|
|
7
|
+
**Extenshi Pay is in beta.** You can prepare your integration and test the paywall in mock mode.
|
|
8
|
+
Seller agreement acceptance and live payments are currently unavailable to third-party developers.
|
|
9
|
+
|
|
7
10
|
- **You are the seller.** Money settles on your own Stripe account (Stripe Connect). extenshi keeps the payment ledger and takes 2% per charge on top of Stripe's fee.
|
|
8
11
|
- **Bundled, no iframe, no remote code.** The paywall is rendered from templates compiled into the SDK and shown in a Shadow DOM. Nothing is fetched at runtime except the JSON API, supporting an extension’s restrictive `content_security_policy`. Store approval depends on the whole extension and is not guaranteed.
|
|
9
12
|
- **Anonymous until the payment.** The SDK mints a random `endUserRef` on first run and stores it in `chrome.storage.local`. No account, no e-mail, no fingerprint. The buyer authenticates inside the hosted checkout, never in your extension.
|
|
@@ -58,19 +61,37 @@ await pay.getEntitlement() // { items, features, verified, source, … }
|
|
|
58
61
|
pay.onEntitlementChange((e) => render(e))
|
|
59
62
|
```
|
|
60
63
|
|
|
64
|
+
### Free access by country
|
|
65
|
+
|
|
66
|
+
In Dojo, open the Pay application's **Offers → Free access by country**. Selected countries get the features of all active offers. The server uses the country of the current connection at each licence check. A missing country or an empty selection uses ordinary billing. The trial clock keeps running. Existing subscriptions keep their billing terms.
|
|
67
|
+
|
|
68
|
+
Use `hasFeature(feature)` or `requireFeature(feature)` to unlock tools. SDK 0.12 and later exposes the regional grant's expiry in `getEntitlement().regionalFreeUntil` (Unix milliseconds). `isPaid()` and `items` describe purchases. Regional access can continue offline until its signed deadline, up to 48 hours. Older SDKs expose the regional grant as a temporary entitlement item.
|
|
69
|
+
|
|
70
|
+
|
|
61
71
|
The envelope is cached in `chrome.storage.local` (default refresh TTL 1 h). Paid
|
|
62
72
|
access requires a valid Ed25519 signature. Unsigned, modified or unverifiable
|
|
63
73
|
responses never unlock features outside explicit `mock: true` mode. A missing key
|
|
64
74
|
or unsupported WebCrypto Ed25519 implementation reports `VERIFICATION_UNAVAILABLE`
|
|
65
75
|
through `onError`; initialization still resolves with access locked.
|
|
66
76
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
77
|
+
Which key verifies a license, in order:
|
|
78
|
+
|
|
79
|
+
1. the key the server returned in this browser session;
|
|
80
|
+
2. `entitlementPublicKey` from your configuration, when you bundle one;
|
|
81
|
+
3. without a bundled key, the server key the SDK saved in `chrome.storage.local`
|
|
82
|
+
next to the license.
|
|
83
|
+
|
|
84
|
+
After a restart with no network, 2 or 3 verifies the cached license until
|
|
85
|
+
`offlineUntil`. They differ in what a user who edits extension storage can do. A
|
|
86
|
+
bundled key is never replaced by one from storage, so an edited license is refused.
|
|
87
|
+
A saved key sits in the same storage as the license: with the license API
|
|
88
|
+
unreachable, a user who rewrites both gets paid access until the SDK next reaches
|
|
89
|
+
the server, which then drops the license. Bundle the key if that matters to you.
|
|
90
|
+
|
|
91
|
+
When the server's signing key is replaced, no known key verifies the new license.
|
|
92
|
+
The SDK then asks the server for its current key once and accepts a license that
|
|
93
|
+
key verifies, also when an older key is bundled. With an outdated bundled key each
|
|
94
|
+
restart needs the network, until you ship the new key.
|
|
74
95
|
|
|
75
96
|
Each signed envelope is bound to its application publishable key and installation.
|
|
76
97
|
Old caches without signed application scope require one online refresh on upgrade.
|
|
@@ -85,6 +106,26 @@ deadline for extension timers. The SDK also emits changes at license expiry whil
|
|
|
85
106
|
its context is alive. Signed issuance permits up to five minutes of server/client
|
|
86
107
|
clock skew; the offline allowance remains bounded by both signed issuance and local
|
|
87
108
|
fetch time. Suspended service workers must check again when they resume.
|
|
109
|
+
|
|
110
|
+
The 48 hours are the allowance of a license that names none. A license may carry a
|
|
111
|
+
signed `offlineSeconds` (set by the server per kind of purchase), which the SDK
|
|
112
|
+
uses instead, up to 366 days.
|
|
113
|
+
|
|
114
|
+
`clockSkew` on the entitlement is set when the device clock differed from the
|
|
115
|
+
server's by more than five minutes at the last license check:
|
|
116
|
+
`{ direction: 'ahead' | 'behind', ms }`. A clock ahead by more than the allowance
|
|
117
|
+
makes a license that was just checked read as due for another check, and a clock
|
|
118
|
+
behind makes the server's license look dated in the future, which the SDK refuses.
|
|
119
|
+
In both cases the device is online and access is paused, so tell the user what to fix:
|
|
120
|
+
|
|
121
|
+
```ts
|
|
122
|
+
const license = await pay.getEntitlement()
|
|
123
|
+
if (license.clockSkew && !license.features.length) {
|
|
124
|
+
show('Check the date and time on this device.')
|
|
125
|
+
} else if (license.requiresOnlineCheck) {
|
|
126
|
+
show('Connect to the internet to confirm your license.')
|
|
127
|
+
}
|
|
128
|
+
```
|
|
88
129
|
Mock mode is exempt from signature and offline limits.
|
|
89
130
|
|
|
90
131
|
The browser must provide Ed25519 in `crypto.subtle` in a secure context. Test your
|
|
@@ -113,6 +154,43 @@ The offer's description is shown next to the price, once: when the header falls
|
|
|
113
154
|
|
|
114
155
|
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.
|
|
115
156
|
|
|
157
|
+
### Free trial
|
|
158
|
+
|
|
159
|
+
Set the trial length on the Pay application (Dojo Payments → Free trial, `set_pay_trial`, or
|
|
160
|
+
`trialDays` on `create_pay_app`). The server starts one clock per installation at its first
|
|
161
|
+
license read and signs `{ startedAt, endsAt }` into the license, so the extension stores no start
|
|
162
|
+
date of its own and switching plans never restarts it. Requires a backend with trial support
|
|
163
|
+
(catalog-bff, November 2026); an older one sends no trial and `getTrial()` returns `null`.
|
|
164
|
+
|
|
165
|
+
```ts
|
|
166
|
+
const trial = await pay.getTrial() // { active, startedAt, endsAt, daysLeft, requiresOnlineCheck } | null
|
|
167
|
+
const unlocked = (await pay.hasFeature('full')) || trial?.active === true
|
|
168
|
+
|
|
169
|
+
pay.on('trial:ending', (t) => setBadge(`${t.daysLeft}d`)) // trialEndingDays before the end (default 2)
|
|
170
|
+
pay.on('trial:ended', () => pay.showTrialEnded({ feedbackFormUrl: 'https://feedback.extenshi.io/f/<code>' }))
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
- `getTrial()` reads the verified license only, so it answers offline from the cache. Like paid
|
|
174
|
+
access, `active` needs a license check within 48 hours (`requiresOnlineCheck` says when one is
|
|
175
|
+
due), and the signed issue time is a floor, so turning the clock back does not reopen an ended
|
|
176
|
+
trial. Check trial access separately from feature access.
|
|
177
|
+
- `trial:ending` and `trial:ended` (the `trialEnding` / `trialEnded` of the spec, named like the
|
|
178
|
+
other `ns:verb` events) fire once per installation and trial; the marker is kept in the SDK's
|
|
179
|
+
storage, so a popup opened later does not repeat them. They do not fire while the user has
|
|
180
|
+
paid access. Render the current state from `getTrial()`.
|
|
181
|
+
- `showTrialEnded()` (full bundle) is the paywall with "Your free trial has ended", "tools are
|
|
182
|
+
paused, settings are kept", the plans and "Restore purchase" (when recovery is on), in the
|
|
183
|
+
user's language. The default text promises the settings are kept: pass `description` if your
|
|
184
|
+
extension does not keep them. `feedbackFormUrl` (HTTPS) adds a "Share feedback" button that
|
|
185
|
+
opens the form with `src=trial_end` and nothing that identifies the installation.
|
|
186
|
+
- The clock belongs to the installation's random `endUserRef`. **A reinstall starts a new
|
|
187
|
+
trial**, with or without browser sync: uninstalling clears the extension's `storage.sync` from
|
|
188
|
+
the account too, nothing else identifies the user, and the SDK does not fingerprint.
|
|
189
|
+
- The SDK keeps the start date (only the date, never the id) in `storage.sync` and sends it back
|
|
190
|
+
as `trialStartedHint`, so another device on the same synced browser account continues the same
|
|
191
|
+
trial; the server lets it move a start only earlier. `syncTrialStart: false` turns this off.
|
|
192
|
+
- `mockData: { trial: { days: 7 } }` previews a trial in mock mode.
|
|
193
|
+
|
|
116
194
|
### Restore a purchase in another browser
|
|
117
195
|
|
|
118
196
|
```typescript
|
|
@@ -128,7 +206,34 @@ Run recovery in an extension page or background context. It creates a random cla
|
|
|
128
206
|
|
|
129
207
|
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.
|
|
130
208
|
|
|
131
|
-
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
|
|
209
|
+
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()`.
|
|
210
|
+
|
|
211
|
+
### Cloud backup of settings (0.11.0)
|
|
212
|
+
|
|
213
|
+
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.
|
|
214
|
+
|
|
215
|
+
```ts
|
|
216
|
+
import { ExtenshiStorage } from '@extenshi/storage'
|
|
217
|
+
|
|
218
|
+
const storage = ExtenshiStorage.create({
|
|
219
|
+
projectKey: EXTENSHI_CONFIG.PROJECT_ID,
|
|
220
|
+
namespace: 'reading-preferences',
|
|
221
|
+
schemaVersion: 1,
|
|
222
|
+
cloud: { getToken: () => pay.cloudBackupToken() },
|
|
223
|
+
})
|
|
224
|
+
|
|
225
|
+
// "Back up settings" (an extension page): the hosted page shows the storage disclosure first.
|
|
226
|
+
const result = await pay.enableCloudBackup()
|
|
227
|
+
if (result.state === 'complete') console.log(result.cloudBackup) // 'on' | 'no_consent' | 'license_required'
|
|
228
|
+
|
|
229
|
+
await pay.disableCloudBackup() // "Turn off" on this installation; the cloud copy stays
|
|
230
|
+
await pay.deleteCloudBackup() // "Delete cloud copy": all records, and backup off everywhere
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
- 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.
|
|
234
|
+
- 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.
|
|
235
|
+
- `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.
|
|
236
|
+
- `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.
|
|
132
237
|
|
|
133
238
|
### License details and author contact
|
|
134
239
|
|
|
@@ -196,18 +301,32 @@ const pay = new ExtenshiPay({
|
|
|
196
301
|
entitlements: [],
|
|
197
302
|
checkoutEnabled: true,
|
|
198
303
|
claimAfterPolls: 2,
|
|
304
|
+
seller: {
|
|
305
|
+
displayName: 'Reader Author',
|
|
306
|
+
supportUrl: 'https://example.com/support', // or a plain email address
|
|
307
|
+
termsUrl: 'https://example.com/terms',
|
|
308
|
+
refundPolicyUrl: 'https://example.com/terms#refunds',
|
|
309
|
+
},
|
|
199
310
|
},
|
|
200
311
|
})
|
|
201
312
|
```
|
|
202
313
|
|
|
203
314
|
No network, no backend: develop the paywall and the gating offline.
|
|
204
315
|
|
|
316
|
+
`seller` stands in for the seller details a live offer carries: the paywall and
|
|
317
|
+
the license panel show the name and the support, terms and refund links, and the
|
|
318
|
+
withdrawal-waiver text names the seller. Without it the mock paywall says
|
|
319
|
+
"License provider details are unavailable." and the waiver names the project;
|
|
320
|
+
`seller: null` also disables the purchase button, as a live offer without seller
|
|
321
|
+
details does. `withdrawalWaiver` (default: required, current version) previews
|
|
322
|
+
the waiver checkbox; `null` previews a seller outside the EEA/UK.
|
|
323
|
+
|
|
205
324
|
## Configuration
|
|
206
325
|
|
|
207
326
|
| Option | Default | Notes |
|
|
208
327
|
|---|---|---|
|
|
209
328
|
| `publishableKey` | — | required, `pk_ext_` + 32 hex |
|
|
210
|
-
| `entitlementPublicKey` | fetched from API | raw 32-byte Ed25519 public key in base64; bundle it
|
|
329
|
+
| `entitlementPublicKey` | fetched from API and saved | raw 32-byte Ed25519 public key in base64; bundle it so a key from storage is never used |
|
|
211
330
|
| `apiUrl` | `https://bff.extenshi.io` | |
|
|
212
331
|
| `cacheTtlMs` | `3600000` | entitlement cache TTL |
|
|
213
332
|
| `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) |
|
|
@@ -215,24 +334,26 @@ No network, no backend: develop the paywall and the gating offline.
|
|
|
215
334
|
| `theme` | — | `mode`, `primaryColor`, `fontFamily`, `borderRadius`, `customCss` |
|
|
216
335
|
| `mock` / `mockData` | `false` | offline development |
|
|
217
336
|
| `onReady` / `onError` | — | callbacks; the same events are on `pay.on(...)` |
|
|
337
|
+
| `trialEndingDays` | `2` | days before the trial's end that `trial:ending` fires; `0` turns it off |
|
|
338
|
+
| `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 |
|
|
218
339
|
|
|
219
|
-
Events: `ready`, `entitlement:changed`, `checkout:started`, `checkout:completed`, `checkout:canceled`, `checkout:expired`, `error`.
|
|
340
|
+
Events: `ready`, `entitlement:changed`, `checkout:started`, `checkout:completed`, `checkout:canceled`, `checkout:expired`, `trial:ending`, `trial:ended`, `error`.
|
|
220
341
|
|
|
221
342
|
## What leaves the extension
|
|
222
343
|
|
|
223
|
-
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.
|
|
344
|
+
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.
|
|
224
345
|
|
|
225
346
|
## Bundle sizes (gzip)
|
|
226
347
|
|
|
227
|
-
Measured
|
|
348
|
+
Measured at 0.11.0 the way `scripts/pay-sdk-release-check.mjs` does (gzip bytes; ESM, before consumer tree shaking):
|
|
228
349
|
|
|
229
350
|
| Bundle | Size |
|
|
230
351
|
|---|---|
|
|
231
|
-
| Full `extenshi-pay.mjs` |
|
|
232
|
-
| Full minified `extenshi-pay.min.mjs` |
|
|
233
|
-
| Lite `extenshi-pay-lite.mjs` |
|
|
234
|
-
| Core `core.mjs` |
|
|
235
|
-
| Paywall `paywall.mjs` |
|
|
352
|
+
| Full `extenshi-pay.mjs` | 63,578 B |
|
|
353
|
+
| Full minified `extenshi-pay.min.mjs` | 45,459 B |
|
|
354
|
+
| Lite `extenshi-pay-lite.mjs` | 26,175 B |
|
|
355
|
+
| Core `core.mjs` | 27,195 B |
|
|
356
|
+
| Paywall `paywall.mjs` | 34,402 B |
|
|
236
357
|
|
|
237
358
|
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.
|
|
238
359
|
|
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,GAA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.*` 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,gBAAgB,CAAA;AAE/C,qBAAa,MAAM;IAEjB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,cAAc;gBADd,SAAS,EAAE,SAAS,EACpB,cAAc,EAAE,MAAM;IAGxC
|
|
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,iBAAiB,EACjB,yBAAyB,EACzB,iBAAiB,EACjB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAA;AACtE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE/C,qBAAa,MAAM;IAEjB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,cAAc;gBADd,SAAS,EAAE,SAAS,EACpB,cAAc,EAAE,MAAM;IAGxC;;;;OAIG;IACH,oBAAoB,CACnB,cAAc,EAAE,MAAM,EACtB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,EACtB,OAAO,CAAC,EAAE,iBAAiB,GACzB,OAAO,CAAC,yBAAyB,CAAC;IASrC,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAQ7F,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAO3D;;;;OAIG;IACH,cAAc,CACb,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,MAAM,EAClB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,EACtB,gBAAgB,CAAC,EAAE,uBAAuB,GACxC,OAAO,CAAC,kBAAkB,CAAC;IAY9B,YAAY,CAAC,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.12.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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B;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":"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AAa,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAA;AACnF,cAAc,mBAAmB,CAAA;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AACtD,YAAY,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,YAAY,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,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":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