@extenshi/pay 0.7.0 → 0.8.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 +13 -9
- package/dist/api/mock.d.ts +4 -0
- package/dist/api/mock.d.ts.map +1 -1
- package/dist/api/pay-api.d.ts +10 -3
- package/dist/api/pay-api.d.ts.map +1 -1
- package/dist/api/transport.d.ts.map +1 -1
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/extenshi-pay.d.ts +21 -2
- package/dist/core/extenshi-pay.d.ts.map +1 -1
- package/dist/core/locale.d.ts +13 -0
- package/dist/core/locale.d.ts.map +1 -0
- package/dist/core.d.mts +208 -113
- package/dist/core.d.ts +208 -113
- package/dist/core.js +204 -14
- package/dist/core.js.map +1 -1
- package/dist/core.mjs +204 -15
- package/dist/core.mjs.map +1 -1
- package/dist/extenshi-pay-lite.js +204 -14
- package/dist/extenshi-pay-lite.js.map +1 -1
- package/dist/extenshi-pay-lite.min.js +3 -2
- package/dist/extenshi-pay-lite.min.js.map +1 -1
- package/dist/extenshi-pay-lite.mjs +204 -15
- package/dist/extenshi-pay-lite.mjs.map +1 -1
- package/dist/extenshi-pay.cjs.js +1234 -180
- package/dist/extenshi-pay.cjs.js.map +1 -1
- package/dist/extenshi-pay.d.ts.map +1 -1
- package/dist/extenshi-pay.js +1234 -180
- package/dist/extenshi-pay.js.map +1 -1
- package/dist/extenshi-pay.min.js +3 -2
- package/dist/extenshi-pay.min.js.map +1 -1
- package/dist/extenshi-pay.min.mjs +3 -2
- package/dist/extenshi-pay.min.mjs.map +1 -1
- package/dist/extenshi-pay.mjs +1231 -181
- package/dist/extenshi-pay.mjs.map +1 -1
- package/dist/index.d.mts +268 -117
- package/dist/index.d.ts +268 -117
- package/dist/lite.d.mts +176 -82
- package/dist/lite.d.ts +176 -82
- package/dist/lite.d.ts.map +1 -1
- package/dist/payment/checkout.d.ts.map +1 -1
- package/dist/payment/recovery.d.ts +2 -0
- package/dist/payment/recovery.d.ts.map +1 -1
- package/dist/payment/withdrawal-waiver.d.ts +26 -0
- package/dist/payment/withdrawal-waiver.d.ts.map +1 -0
- package/dist/paywall/billing-profile-picker.d.ts +1 -1
- package/dist/paywall/billing-profile-picker.d.ts.map +1 -1
- package/dist/paywall/i18n.d.ts +94 -0
- package/dist/paywall/i18n.d.ts.map +1 -0
- package/dist/paywall/index.d.ts +2 -1
- package/dist/paywall/index.d.ts.map +1 -1
- package/dist/paywall/license-panel.d.ts +4 -1
- package/dist/paywall/license-panel.d.ts.map +1 -1
- package/dist/paywall/renderer.d.ts +16 -2
- package/dist/paywall/renderer.d.ts.map +1 -1
- package/dist/paywall/seller-details.d.ts +2 -1
- package/dist/paywall/seller-details.d.ts.map +1 -1
- package/dist/paywall/strings.d.ts +6 -4
- package/dist/paywall/strings.d.ts.map +1 -1
- package/dist/paywall.d.mts +93 -7
- package/dist/paywall.d.ts +93 -7
- package/dist/paywall.js +992 -41
- package/dist/paywall.js.map +1 -1
- package/dist/paywall.mjs +990 -42
- package/dist/paywall.mjs.map +1 -1
- package/dist/types/config.d.ts +6 -1
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/contract.d.ts +25 -0
- package/dist/types/contract.d.ts.map +1 -1
- package/dist/types/entitlement.d.ts +22 -0
- package/dist/types/entitlement.d.ts.map +1 -1
- package/dist/types/errors.d.ts +1 -0
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/paywall.d.ts +15 -2
- package/dist/types/paywall.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +3 -11
- package/dist/core.esm.js +0 -1681
- package/dist/core.esm.js.map +0 -1
- package/dist/extenshi-pay-lite.esm.js +0 -1664
- package/dist/extenshi-pay-lite.esm.js.map +0 -1
- package/dist/extenshi-pay.esm.js +0 -2496
- package/dist/extenshi-pay.esm.js.map +0 -1
- package/dist/extenshi-pay.esm.min.js +0 -7
- package/dist/extenshi-pay.esm.min.js.map +0 -1
- package/dist/paywall.esm.js +0 -442
- package/dist/paywall.esm.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# @extenshi/pay
|
|
2
2
|
|
|
3
|
+
[Documentation](https://docs.extenshi.io/developers/pay-sdk) · [npm package](https://www.npmjs.com/package/@extenshi/pay)
|
|
4
|
+
|
|
3
5
|
Payments for browser extensions, bundled into the extension itself.
|
|
4
6
|
|
|
5
7
|
- **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.
|
|
@@ -105,7 +107,7 @@ await pay.showPaywall({
|
|
|
105
107
|
})
|
|
106
108
|
```
|
|
107
109
|
|
|
108
|
-
Templates come from `@extenshi/paywall-templates` and are inlined at build time;
|
|
110
|
+
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, descriptions and features come from the server in the buyer's language when you translated them in dojo (Monetization → Languages) or with `set_pay_offer_translations`. Prices are formatted with `Intl.NumberFormat` in the user's locale.
|
|
109
111
|
|
|
110
112
|
### Restore a purchase in another browser
|
|
111
113
|
|
|
@@ -204,7 +206,7 @@ No network, no backend: develop the paywall and the gating offline.
|
|
|
204
206
|
| `entitlementPublicKey` | fetched from API | raw 32-byte Ed25519 public key in base64; bundle it for offline restart |
|
|
205
207
|
| `apiUrl` | `https://bff.extenshi.io` | |
|
|
206
208
|
| `cacheTtlMs` | `3600000` | entitlement cache TTL |
|
|
207
|
-
| `locale` | browser
|
|
209
|
+
| `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) |
|
|
208
210
|
| `logLevel` | `'warn'` | `'silent' \| 'error' \| 'warn' \| 'info' \| 'debug'` |
|
|
209
211
|
| `theme` | — | `mode`, `primaryColor`, `fontFamily`, `borderRadius`, `customCss` |
|
|
210
212
|
| `mock` / `mockData` | `false` | offline development |
|
|
@@ -214,19 +216,21 @@ Events: `ready`, `entitlement:changed`, `checkout:started`, `checkout:completed`
|
|
|
214
216
|
|
|
215
217
|
## What leaves the extension
|
|
216
218
|
|
|
217
|
-
Normal payment calls send `publishableKey`, `endUserRef` (a random UUID), `sku` and `locale
|
|
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.
|
|
218
220
|
|
|
219
221
|
## Bundle sizes (gzip)
|
|
220
222
|
|
|
221
|
-
Measured from the
|
|
223
|
+
Measured from the working tree after the paywall translations (it. 13 T10 L2; gzip bytes; ESM, before consumer tree shaking):
|
|
222
224
|
|
|
223
225
|
| Bundle | Size |
|
|
224
226
|
|---|---|
|
|
225
|
-
| Full `extenshi-pay.mjs` |
|
|
226
|
-
| Full minified `extenshi-pay.min.mjs` |
|
|
227
|
-
| Lite `extenshi-pay-lite.mjs` | 17,
|
|
228
|
-
| Core `core.mjs` |
|
|
229
|
-
| Paywall `paywall.mjs` |
|
|
227
|
+
| Full `extenshi-pay.mjs` | 50,897 B |
|
|
228
|
+
| Full minified `extenshi-pay.min.mjs` | 38,451 B |
|
|
229
|
+
| Lite `extenshi-pay-lite.mjs` | 17,836 B |
|
|
230
|
+
| Core `core.mjs` | 18,441 B |
|
|
231
|
+
| Paywall `paywall.mjs` | 29,117 B |
|
|
232
|
+
|
|
233
|
+
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.
|
|
230
234
|
|
|
231
235
|
The release validation script prints fresh measurements for each build.
|
|
232
236
|
|
package/dist/api/mock.d.ts
CHANGED
|
@@ -5,12 +5,15 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import type { MockData } from '../types/config.js';
|
|
7
7
|
import { type PayEntitlementItem } from '../types/contract.js';
|
|
8
|
+
import type { WithdrawalWaiverConsent } from '../types/entitlement.js';
|
|
8
9
|
import type { ProcedureKind, Transport } from './transport.js';
|
|
9
10
|
type SessionState = 'open' | 'complete' | 'canceled' | 'expired';
|
|
10
11
|
interface MockSession {
|
|
11
12
|
sku: string;
|
|
12
13
|
polls: number;
|
|
13
14
|
state: SessionState;
|
|
15
|
+
/** What `createCheckout` received, for inspecting the consent in dev/tests. */
|
|
16
|
+
withdrawalWaiver: WithdrawalWaiverConsent | null;
|
|
14
17
|
}
|
|
15
18
|
export declare class MockTransport implements Transport {
|
|
16
19
|
private entitlements;
|
|
@@ -18,6 +21,7 @@ export declare class MockTransport implements Transport {
|
|
|
18
21
|
private readonly projectName;
|
|
19
22
|
private readonly checkoutEnabled;
|
|
20
23
|
private readonly claimAfterPolls;
|
|
24
|
+
private readonly withdrawalWaiver;
|
|
21
25
|
readonly sessions: Map<string, MockSession>;
|
|
22
26
|
constructor(data?: MockData);
|
|
23
27
|
call<T>(procedure: string, _kind: ProcedureKind, input: Record<string, unknown>): Promise<T>;
|
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,
|
|
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,OAA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AQ;CAahB"}
|
package/dist/api/pay-api.d.ts
CHANGED
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
/** Typed wrapper over the SDK-facing `pay.*` procedures. Nothing else is ever called. */
|
|
2
2
|
import type { PayCheckoutClaim, PayCheckoutSession, PayOfferResponse, PayPortalResponse, PayRestoreClaimResponse, PayRestoreSessionResponse, SignedEntitlement } from '../types/contract.js';
|
|
3
|
+
import type { WithdrawalWaiverConsent } from '../types/entitlement.js';
|
|
3
4
|
import type { Transport } from './transport.js';
|
|
4
5
|
export declare class PayApi {
|
|
5
6
|
private readonly transport;
|
|
6
7
|
private readonly publishableKey;
|
|
7
8
|
constructor(transport: Transport, publishableKey: string);
|
|
8
|
-
|
|
9
|
+
/** `locale` opens the hosted recovery page (and its email) in the user's language. */
|
|
10
|
+
createRestoreSession(claimChallenge: string, locale?: string | null): Promise<PayRestoreSessionResponse>;
|
|
9
11
|
claimRestoreSession(sessionId: string, claimSecret: string): Promise<PayRestoreClaimResponse>;
|
|
10
12
|
getOffer(locale?: string | null): Promise<PayOfferResponse>;
|
|
11
|
-
|
|
13
|
+
/**
|
|
14
|
+
* `withdrawalWaiver` is sent only when given. Older BFFs parse the input with
|
|
15
|
+
* a non-strict zod object, which strips the unknown key, so it is safe there.
|
|
16
|
+
* Plain-JS callers passing anything but `accepted: true` send no consent.
|
|
17
|
+
*/
|
|
18
|
+
createCheckout(sku: string, endUserRef: string, locale?: string | null, withdrawalWaiver?: WithdrawalWaiverConsent): Promise<PayCheckoutSession>;
|
|
12
19
|
claimSession(sessionId: string, endUserRef: string): Promise<PayCheckoutClaim>;
|
|
13
20
|
getEntitlement(endUserRef: string): Promise<SignedEntitlement>;
|
|
14
|
-
getPortalUrl(endUserRef: string, customerId?: string): Promise<PayPortalResponse>;
|
|
21
|
+
getPortalUrl(endUserRef: string, customerId?: string, locale?: string | null): Promise<PayPortalResponse>;
|
|
15
22
|
}
|
|
16
23
|
//# 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,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,oBAAoB,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,yBAAyB,CAAC;
|
|
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,sFAAsF;IACtF,oBAAoB,CAAC,cAAc,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,yBAAyB,CAAC;IAQxG,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GA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,EAAE,MAAM,CAAC;YAAC,aAAa,CAAC,EAAE,MAAM,CAAA;SAAE,CAAA;KACjD,CAAA;CACD;AA8BD;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,cAAc,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,gBAAgB,CA8BhG;AAMD,qBAAa,aAAc,YAAW,SAAS;IAC9C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAQ;IAC/B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAQ;IAClC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAQ;IAChC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAc;gBAE5B,OAAO,EAAE,oBAAoB;IAOnC,IAAI,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;YAmBnF,OAAO;CAqCrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/core/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,KAAK,iBAAiB,EAEtB,KAAK,cAAc,EACnB,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/core/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,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,CAiEtE"}
|
|
@@ -30,7 +30,7 @@ export interface ExtenshiPayDeps {
|
|
|
30
30
|
now?: () => number;
|
|
31
31
|
}
|
|
32
32
|
export declare class ExtenshiPayLite {
|
|
33
|
-
static readonly version = "0.
|
|
33
|
+
static readonly version = "0.8.0";
|
|
34
34
|
protected readonly config: ResolvedConfig;
|
|
35
35
|
protected readonly emitter: EventEmitter<ExtenshiPayEvents>;
|
|
36
36
|
protected readonly storage: StorageAdapter;
|
|
@@ -67,7 +67,26 @@ export declare class ExtenshiPayLite {
|
|
|
67
67
|
requireFeature(feature: string, options?: RequireFeatureOptions): Promise<boolean>;
|
|
68
68
|
/** Lite has no UI: a locked feature stays locked. The full SDK shows the paywall here. */
|
|
69
69
|
protected onFeatureLocked(_feature: string, _options: RequireFeatureOptions): Promise<boolean>;
|
|
70
|
-
/**
|
|
70
|
+
/**
|
|
71
|
+
* The withdrawal waiver this offer asks for, with the exact text to show
|
|
72
|
+
* next to an unticked checkbox (buyer's language, seller's name filled in),
|
|
73
|
+
* or null when the seller attested the extension is not distributed in the
|
|
74
|
+
* EEA/UK. For UIs that call `openCheckout()` themselves — Lite, or a custom
|
|
75
|
+
* paywall; the full SDK's paywall does this for you.
|
|
76
|
+
*/
|
|
77
|
+
getWithdrawalWaiver(): Promise<{
|
|
78
|
+
version: string;
|
|
79
|
+
text: string;
|
|
80
|
+
} | null>;
|
|
81
|
+
/**
|
|
82
|
+
* Opens hosted checkout for `sku` in a new tab and resolves when the session settles.
|
|
83
|
+
*
|
|
84
|
+
* Called directly (not from the paywall), this does NOT collect the EU/UK
|
|
85
|
+
* withdrawal waiver. If `getWithdrawalWaiver()` returns one, your UI must
|
|
86
|
+
* collect the buyer's consent and pass it as `options.withdrawalWaiver`;
|
|
87
|
+
* without it this rejects with `WITHDRAWAL_WAIVER_REQUIRED` (the server
|
|
88
|
+
* refuses such a checkout too).
|
|
89
|
+
*/
|
|
71
90
|
openCheckout(sku: string, options?: CheckoutOptions): Promise<CheckoutResult>;
|
|
72
91
|
/** Opens email verification on the hosted page. No email is collected inside the extension. */
|
|
73
92
|
restorePurchase(options?: RestoreOptions): Promise<RestoreResult>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extenshi-pay.d.ts","sourceRoot":"","sources":["../../src/core/extenshi-pay.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;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;AACxD,OAAO,EAAE,kBAAkB,EAAqB,MAAM,2BAA2B,CAAA;AAEjF,OAAO,EAAyB,eAAe,EAAE,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"extenshi-pay.d.ts","sourceRoot":"","sources":["../../src/core/extenshi-pay.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;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;AACxD,OAAO,EAAE,kBAAkB,EAAqB,MAAM,2BAA2B,CAAA;AAEjF,OAAO,EAAyB,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAG/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,qBAAqB,EACrB,WAAW,EACX,qBAAqB,EACrB,cAAc,EACd,qBAAqB,EACrB,cAAc,EACd,aAAa,EACb,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAe,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAClE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAI3D,OAAO,EAAE,YAAY,EAAE,KAAK,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAEhE,OAAO,EAAiB,KAAK,cAAc,EAAE,MAAM,cAAc,C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,EAAE,QAAQ,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;IAOf,+EAA+E;IAC/E,SAAS,CAAC,UAAU,CAAC,KAAK,UAAQ,GAAG,OAAO,CAAC,gBAAgB,CAAC;YAkBhD,YAAY;IAI1B,SAAS,CAAC,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,gBAAgB;CAMvD"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The user's language as the SDK sends it. Kept apart from the paywall
|
|
3
|
+
* dictionary (../paywall/i18n.ts) so the Lite and core bundles, which never
|
|
4
|
+
* render UI, do not carry the translations.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* A browser tag as the SDK sends it: `pt_BR` → `pt-BR`, `es-419` → `es`,
|
|
8
|
+
* `zh-Hant-TW` → `zh-TW`; null for anything that is not a language tag.
|
|
9
|
+
*/
|
|
10
|
+
export declare function wireLocale(raw: unknown): string | null;
|
|
11
|
+
/** The browser UI language (`chrome.i18n.getUILanguage()`, else `navigator.language`), or null. */
|
|
12
|
+
export declare function browserLocale(): string | null;
|
|
13
|
+
//# sourceMappingURL=locale.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locale.d.ts","sourceRoot":"","sources":["../../src/core/locale.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH;;;GAGG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAetD;AAED,mGAAmG;AACnG,wBAAgB,aAAa,IAAI,MAAM,GAAG,IAAI,CAa7C"}
|
package/dist/core.d.mts
CHANGED
|
@@ -62,6 +62,28 @@ interface PayOfferResponse {
|
|
|
62
62
|
offers: PayOfferDto[];
|
|
63
63
|
/** Base64 Ed25519 public key for `SignedEntitlement.signature`; null when unsigned. */
|
|
64
64
|
entitlementPublicKey: string | null;
|
|
65
|
+
/**
|
|
66
|
+
* The language the offers' text is in when the seller translated them
|
|
67
|
+
* (it. 13 T10 L2); absent from older servers and for single-language offers.
|
|
68
|
+
*/
|
|
69
|
+
locale?: string;
|
|
70
|
+
/**
|
|
71
|
+
* Set when the paywall must show an unticked withdrawal-waiver checkbox and
|
|
72
|
+
* send the accepted `version` with `createCheckout`. Null when the seller
|
|
73
|
+
* attested the extension is not distributed in the EEA/UK; absent from
|
|
74
|
+
* older servers (the SDK then shows no checkbox).
|
|
75
|
+
*/
|
|
76
|
+
withdrawalWaiver?: PayWithdrawalWaiver | null;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Version of the buyer-facing withdrawal waiver text the paywall shows (EU/EEA
|
|
80
|
+
* digital content, Directive 2011/83/EU art. 16(m); UK CCR 2013 reg. 37). The
|
|
81
|
+
* text itself lives in the SDK dictionary under the same version; bump both
|
|
82
|
+
* together so a recorded consent always names the words the buyer saw.
|
|
83
|
+
*/
|
|
84
|
+
declare const PAY_WITHDRAWAL_WAIVER_VERSION = "2026-10-v1";
|
|
85
|
+
interface PayWithdrawalWaiver {
|
|
86
|
+
version: string;
|
|
65
87
|
}
|
|
66
88
|
interface PayEntitlementItem {
|
|
67
89
|
/** Optional for old signed caches and older servers. */
|
|
@@ -125,6 +147,7 @@ declare const PAY_ERRORS: {
|
|
|
125
147
|
readonly GATEWAY_UNAVAILABLE: "PAY_GATEWAY_UNAVAILABLE";
|
|
126
148
|
readonly RATE_LIMITED: "PAY_RATE_LIMITED";
|
|
127
149
|
readonly INVALID_KEY: "PAY_INVALID_KEY";
|
|
150
|
+
readonly WITHDRAWAL_WAIVER_REQUIRED: "PAY_WITHDRAWAL_WAIVER_REQUIRED";
|
|
128
151
|
};
|
|
129
152
|
type PayErrorCode = (typeof PAY_ERRORS)[keyof typeof PAY_ERRORS];
|
|
130
153
|
/**
|
|
@@ -168,6 +191,8 @@ interface PaySellerPublic {
|
|
|
168
191
|
/** HTTPS support page or plain email address. */
|
|
169
192
|
supportUrl: string;
|
|
170
193
|
termsUrl: string | null;
|
|
194
|
+
/** Optional for older servers: refunds section of the license terms. */
|
|
195
|
+
refundPolicyUrl?: string | null;
|
|
171
196
|
}
|
|
172
197
|
|
|
173
198
|
declare const ERROR_CODES: {
|
|
@@ -184,6 +209,7 @@ declare const ERROR_CODES: {
|
|
|
184
209
|
readonly GATEWAY_UNAVAILABLE: "GATEWAY_UNAVAILABLE";
|
|
185
210
|
readonly CHECKOUT_UNAVAILABLE: "CHECKOUT_UNAVAILABLE";
|
|
186
211
|
readonly PAYWALL_UNAVAILABLE: "PAYWALL_UNAVAILABLE";
|
|
212
|
+
readonly WITHDRAWAL_WAIVER_REQUIRED: "WITHDRAWAL_WAIVER_REQUIRED";
|
|
187
213
|
readonly UNKNOWN: "UNKNOWN";
|
|
188
214
|
};
|
|
189
215
|
type ErrorCode = (typeof ERROR_CODES)[keyof typeof ERROR_CODES];
|
|
@@ -222,6 +248,11 @@ interface MockData {
|
|
|
222
248
|
checkoutEnabled?: boolean;
|
|
223
249
|
/** How many `claimSession` polls answer `pending` before a mock checkout completes (default 1). */
|
|
224
250
|
claimAfterPolls?: number;
|
|
251
|
+
/**
|
|
252
|
+
* Offer's withdrawal waiver (default: required, current version, so the
|
|
253
|
+
* paywall previews the checkbox). `null` previews a seller outside the EEA/UK.
|
|
254
|
+
*/
|
|
255
|
+
withdrawalWaiver?: PayWithdrawalWaiver | null;
|
|
225
256
|
}
|
|
226
257
|
interface ExtenshiPayConfig {
|
|
227
258
|
/** `pk_ext_` + 32 hex characters, from the project's Monetization tab. */
|
|
@@ -261,6 +292,145 @@ declare const DEFAULT_API_URL = "https://bff.extenshi.io";
|
|
|
261
292
|
declare const DEFAULT_CACHE_TTL_MS: number;
|
|
262
293
|
declare const MAX_CACHE_TTL_MS: number;
|
|
263
294
|
|
|
295
|
+
type PaywallMode = 'modal' | 'inline' | 'sidebar' | 'fullscreen' | 'minimal';
|
|
296
|
+
/**
|
|
297
|
+
* Every user-visible string the paywall adds on top of the templates. The SDK
|
|
298
|
+
* fills them in the configured `locale` (src/paywall/i18n.ts); pass `strings`
|
|
299
|
+
* to override any of them.
|
|
300
|
+
*/
|
|
301
|
+
interface PaywallStrings {
|
|
302
|
+
title: string;
|
|
303
|
+
description: string;
|
|
304
|
+
upgrade: string;
|
|
305
|
+
cancel: string;
|
|
306
|
+
dismiss: string;
|
|
307
|
+
remindLater: string;
|
|
308
|
+
continueFree: string;
|
|
309
|
+
checkoutUnavailable: string;
|
|
310
|
+
periodMonth: string;
|
|
311
|
+
periodYear: string;
|
|
312
|
+
periodOnce: string;
|
|
313
|
+
footer: string;
|
|
314
|
+
restorePurchase: string;
|
|
315
|
+
/** Template headings and plan labels (were fixed English text in the templates). */
|
|
316
|
+
featuresHeading: string;
|
|
317
|
+
plansHeading: string;
|
|
318
|
+
freePlanName: string;
|
|
319
|
+
premiumPlanName: string;
|
|
320
|
+
popularBadge: string;
|
|
321
|
+
unlockHeading: string;
|
|
322
|
+
}
|
|
323
|
+
interface PaywallOptions {
|
|
324
|
+
/** Template to render (default `modal`). */
|
|
325
|
+
mode?: PaywallMode;
|
|
326
|
+
/** Offer to feature; defaults to the first active offer. */
|
|
327
|
+
sku?: string;
|
|
328
|
+
title?: string;
|
|
329
|
+
description?: string;
|
|
330
|
+
/** Overrides the offer's `features[]`. */
|
|
331
|
+
features?: string[];
|
|
332
|
+
/** Free-tier bullets for the comparison templates (`inline`, `fullscreen`). */
|
|
333
|
+
freeFeatures?: string[];
|
|
334
|
+
theme?: ThemeConfig;
|
|
335
|
+
/** Mount point for `inline` mode (default `document.body`). */
|
|
336
|
+
container?: HTMLElement;
|
|
337
|
+
strings?: Partial<PaywallStrings>;
|
|
338
|
+
/** `consent` carries the withdrawal waiver when the paywall showed one. */
|
|
339
|
+
onUpgrade?: (sku: string, consent?: UpgradeConsent) => void;
|
|
340
|
+
onClose?: () => void;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
type EntitlementSource = 'network' | 'cache' | 'mock' | 'none';
|
|
344
|
+
/** The SDK's view of the server projection, with `expiresAt` applied locally. */
|
|
345
|
+
interface Entitlement {
|
|
346
|
+
items: PayEntitlementItem[];
|
|
347
|
+
/** Union of `features[]` over active/grace items. */
|
|
348
|
+
features: string[];
|
|
349
|
+
/** True only when the Ed25519 signature was checked against the project's key. */
|
|
350
|
+
verified: boolean;
|
|
351
|
+
issuedAt: string | null;
|
|
352
|
+
/** `Date.now()` of the last successful fetch, or null when nothing was ever fetched. */
|
|
353
|
+
fetchedAt: number | null;
|
|
354
|
+
/** Paid access is paused until a successful online check, not a license expiry. */
|
|
355
|
+
requiresOnlineCheck?: boolean;
|
|
356
|
+
/** Local offline-access deadline; null for mock mode or no cached license. */
|
|
357
|
+
offlineUntil?: number | null;
|
|
358
|
+
source: EntitlementSource;
|
|
359
|
+
}
|
|
360
|
+
interface GetEntitlementOptions {
|
|
361
|
+
/** Skip the cache TTL and hit the network. */
|
|
362
|
+
force?: boolean;
|
|
363
|
+
}
|
|
364
|
+
type CheckoutState = 'complete' | 'canceled' | 'expired' | 'timeout';
|
|
365
|
+
interface CheckoutResult {
|
|
366
|
+
state: CheckoutState;
|
|
367
|
+
sku: string;
|
|
368
|
+
sessionId: string;
|
|
369
|
+
entitlement?: Entitlement;
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* The buyer ticked the withdrawal-waiver checkbox (EU/EEA/UK digital content).
|
|
373
|
+
* `version` names the waiver words that were shown (`PAY_WITHDRAWAL_WAIVER_VERSION`).
|
|
374
|
+
*/
|
|
375
|
+
interface WithdrawalWaiverConsent {
|
|
376
|
+
version: string;
|
|
377
|
+
accepted: true;
|
|
378
|
+
}
|
|
379
|
+
/** What a paywall upgrade click carries besides the SKU. */
|
|
380
|
+
interface UpgradeConsent {
|
|
381
|
+
withdrawalWaiver?: WithdrawalWaiverConsent;
|
|
382
|
+
}
|
|
383
|
+
interface CheckoutOptions {
|
|
384
|
+
locale?: string;
|
|
385
|
+
/**
|
|
386
|
+
* Withdrawal-waiver consent, sent with `pay.createCheckout`. The paywall
|
|
387
|
+
* collects it itself. When you call `openCheckout()` from your own UI, ask
|
|
388
|
+
* `getWithdrawalWaiver()` first: if it returns a waiver, YOUR UI must show an
|
|
389
|
+
* unticked checkbox with exactly its `text` and pass
|
|
390
|
+
* `{ version, accepted: true }` here only once the buyer ticked it. Without
|
|
391
|
+
* it `openCheckout()` rejects with `WITHDRAWAL_WAIVER_REQUIRED`, and so does
|
|
392
|
+
* the server.
|
|
393
|
+
*/
|
|
394
|
+
withdrawalWaiver?: WithdrawalWaiverConsent;
|
|
395
|
+
/** Stop polling `claimSession` after this long (default 10 minutes). */
|
|
396
|
+
timeoutMs?: number;
|
|
397
|
+
/** Poll interval (default 2 seconds). */
|
|
398
|
+
pollIntervalMs?: number;
|
|
399
|
+
/** Override how the hosted checkout URL is opened (default: `chrome.tabs.create`, then `window.open`). */
|
|
400
|
+
openUrl?: (url: string) => void | Promise<void>;
|
|
401
|
+
}
|
|
402
|
+
interface RequireFeatureOptions {
|
|
403
|
+
/** Full bundle only: show the paywall when the feature is locked (default true). */
|
|
404
|
+
showPaywall?: boolean;
|
|
405
|
+
onUnlock?: () => void;
|
|
406
|
+
onCancel?: () => void;
|
|
407
|
+
/** Paywall options used when `showPaywall` is true. */
|
|
408
|
+
paywall?: PaywallOptions;
|
|
409
|
+
}
|
|
410
|
+
interface RestoreOptions {
|
|
411
|
+
timeoutMs?: number;
|
|
412
|
+
pollIntervalMs?: number;
|
|
413
|
+
signal?: AbortSignal;
|
|
414
|
+
openUrl?: (url: string) => void | Promise<void>;
|
|
415
|
+
}
|
|
416
|
+
type RestoreResult = {
|
|
417
|
+
state: 'complete';
|
|
418
|
+
entitlement: Entitlement;
|
|
419
|
+
} | {
|
|
420
|
+
state: 'timeout' | 'expired' | 'canceled';
|
|
421
|
+
};
|
|
422
|
+
interface CustomerPortalOptions {
|
|
423
|
+
openUrl?: (url: string) => void | Promise<void>;
|
|
424
|
+
/** Return a listed profile ID, or null to cancel. Required by Lite for multiple profiles. */
|
|
425
|
+
selectAccount?: (accounts: PayPortalAccount[]) => string | null | Promise<string | null>;
|
|
426
|
+
}
|
|
427
|
+
interface LicenseSummary {
|
|
428
|
+
projectName: string | null;
|
|
429
|
+
seller: PaySellerPublic | null;
|
|
430
|
+
entitlement: Entitlement;
|
|
431
|
+
recoveryEnabled: boolean;
|
|
432
|
+
}
|
|
433
|
+
|
|
264
434
|
/**
|
|
265
435
|
* HTTP transport for the BFF's tRPC endpoint (`/api/trpc/<procedure>`).
|
|
266
436
|
*
|
|
@@ -323,6 +493,8 @@ interface MockSession {
|
|
|
323
493
|
sku: string;
|
|
324
494
|
polls: number;
|
|
325
495
|
state: SessionState;
|
|
496
|
+
/** What `createCheckout` received, for inspecting the consent in dev/tests. */
|
|
497
|
+
withdrawalWaiver: WithdrawalWaiverConsent | null;
|
|
326
498
|
}
|
|
327
499
|
declare class MockTransport implements Transport {
|
|
328
500
|
private entitlements;
|
|
@@ -330,6 +502,7 @@ declare class MockTransport implements Transport {
|
|
|
330
502
|
private readonly projectName;
|
|
331
503
|
private readonly checkoutEnabled;
|
|
332
504
|
private readonly claimAfterPolls;
|
|
505
|
+
private readonly withdrawalWaiver;
|
|
333
506
|
readonly sessions: Map<string, MockSession>;
|
|
334
507
|
constructor(data?: MockData);
|
|
335
508
|
call<T>(procedure: string, _kind: ProcedureKind, input: Record<string, unknown>): Promise<T>;
|
|
@@ -350,13 +523,19 @@ declare class PayApi {
|
|
|
350
523
|
private readonly transport;
|
|
351
524
|
private readonly publishableKey;
|
|
352
525
|
constructor(transport: Transport, publishableKey: string);
|
|
353
|
-
|
|
526
|
+
/** `locale` opens the hosted recovery page (and its email) in the user's language. */
|
|
527
|
+
createRestoreSession(claimChallenge: string, locale?: string | null): Promise<PayRestoreSessionResponse>;
|
|
354
528
|
claimRestoreSession(sessionId: string, claimSecret: string): Promise<PayRestoreClaimResponse>;
|
|
355
529
|
getOffer(locale?: string | null): Promise<PayOfferResponse>;
|
|
356
|
-
|
|
530
|
+
/**
|
|
531
|
+
* `withdrawalWaiver` is sent only when given. Older BFFs parse the input with
|
|
532
|
+
* a non-strict zod object, which strips the unknown key, so it is safe there.
|
|
533
|
+
* Plain-JS callers passing anything but `accepted: true` send no consent.
|
|
534
|
+
*/
|
|
535
|
+
createCheckout(sku: string, endUserRef: string, locale?: string | null, withdrawalWaiver?: WithdrawalWaiverConsent): Promise<PayCheckoutSession>;
|
|
357
536
|
claimSession(sessionId: string, endUserRef: string): Promise<PayCheckoutClaim>;
|
|
358
537
|
getEntitlement(endUserRef: string): Promise<SignedEntitlement>;
|
|
359
|
-
getPortalUrl(endUserRef: string, customerId?: string): Promise<PayPortalResponse>;
|
|
538
|
+
getPortalUrl(endUserRef: string, customerId?: string, locale?: string | null): Promise<PayPortalResponse>;
|
|
360
539
|
}
|
|
361
540
|
|
|
362
541
|
/**
|
|
@@ -400,111 +579,6 @@ declare class MemoryStorage implements StorageAdapter {
|
|
|
400
579
|
}
|
|
401
580
|
declare function createStorage(): StorageAdapter;
|
|
402
581
|
|
|
403
|
-
type PaywallMode = 'modal' | 'inline' | 'sidebar' | 'fullscreen' | 'minimal';
|
|
404
|
-
/** Every user-visible string the SDK adds on top of the templates (English only; iteration 12 T9 swaps locales). */
|
|
405
|
-
interface PaywallStrings {
|
|
406
|
-
title: string;
|
|
407
|
-
description: string;
|
|
408
|
-
upgrade: string;
|
|
409
|
-
cancel: string;
|
|
410
|
-
dismiss: string;
|
|
411
|
-
remindLater: string;
|
|
412
|
-
continueFree: string;
|
|
413
|
-
checkoutUnavailable: string;
|
|
414
|
-
periodMonth: string;
|
|
415
|
-
periodYear: string;
|
|
416
|
-
periodOnce: string;
|
|
417
|
-
footer: string;
|
|
418
|
-
restorePurchase: string;
|
|
419
|
-
}
|
|
420
|
-
interface PaywallOptions {
|
|
421
|
-
/** Template to render (default `modal`). */
|
|
422
|
-
mode?: PaywallMode;
|
|
423
|
-
/** Offer to feature; defaults to the first active offer. */
|
|
424
|
-
sku?: string;
|
|
425
|
-
title?: string;
|
|
426
|
-
description?: string;
|
|
427
|
-
/** Overrides the offer's `features[]`. */
|
|
428
|
-
features?: string[];
|
|
429
|
-
/** Free-tier bullets for the comparison templates (`inline`, `fullscreen`). */
|
|
430
|
-
freeFeatures?: string[];
|
|
431
|
-
theme?: ThemeConfig;
|
|
432
|
-
/** Mount point for `inline` mode (default `document.body`). */
|
|
433
|
-
container?: HTMLElement;
|
|
434
|
-
strings?: Partial<PaywallStrings>;
|
|
435
|
-
onUpgrade?: (sku: string) => void;
|
|
436
|
-
onClose?: () => void;
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
type EntitlementSource = 'network' | 'cache' | 'mock' | 'none';
|
|
440
|
-
/** The SDK's view of the server projection, with `expiresAt` applied locally. */
|
|
441
|
-
interface Entitlement {
|
|
442
|
-
items: PayEntitlementItem[];
|
|
443
|
-
/** Union of `features[]` over active/grace items. */
|
|
444
|
-
features: string[];
|
|
445
|
-
/** True only when the Ed25519 signature was checked against the project's key. */
|
|
446
|
-
verified: boolean;
|
|
447
|
-
issuedAt: string | null;
|
|
448
|
-
/** `Date.now()` of the last successful fetch, or null when nothing was ever fetched. */
|
|
449
|
-
fetchedAt: number | null;
|
|
450
|
-
/** Paid access is paused until a successful online check, not a license expiry. */
|
|
451
|
-
requiresOnlineCheck?: boolean;
|
|
452
|
-
/** Local offline-access deadline; null for mock mode or no cached license. */
|
|
453
|
-
offlineUntil?: number | null;
|
|
454
|
-
source: EntitlementSource;
|
|
455
|
-
}
|
|
456
|
-
interface GetEntitlementOptions {
|
|
457
|
-
/** Skip the cache TTL and hit the network. */
|
|
458
|
-
force?: boolean;
|
|
459
|
-
}
|
|
460
|
-
type CheckoutState = 'complete' | 'canceled' | 'expired' | 'timeout';
|
|
461
|
-
interface CheckoutResult {
|
|
462
|
-
state: CheckoutState;
|
|
463
|
-
sku: string;
|
|
464
|
-
sessionId: string;
|
|
465
|
-
entitlement?: Entitlement;
|
|
466
|
-
}
|
|
467
|
-
interface CheckoutOptions {
|
|
468
|
-
locale?: string;
|
|
469
|
-
/** Stop polling `claimSession` after this long (default 10 minutes). */
|
|
470
|
-
timeoutMs?: number;
|
|
471
|
-
/** Poll interval (default 2 seconds). */
|
|
472
|
-
pollIntervalMs?: number;
|
|
473
|
-
/** Override how the hosted checkout URL is opened (default: `chrome.tabs.create`, then `window.open`). */
|
|
474
|
-
openUrl?: (url: string) => void | Promise<void>;
|
|
475
|
-
}
|
|
476
|
-
interface RequireFeatureOptions {
|
|
477
|
-
/** Full bundle only: show the paywall when the feature is locked (default true). */
|
|
478
|
-
showPaywall?: boolean;
|
|
479
|
-
onUnlock?: () => void;
|
|
480
|
-
onCancel?: () => void;
|
|
481
|
-
/** Paywall options used when `showPaywall` is true. */
|
|
482
|
-
paywall?: PaywallOptions;
|
|
483
|
-
}
|
|
484
|
-
interface RestoreOptions {
|
|
485
|
-
timeoutMs?: number;
|
|
486
|
-
pollIntervalMs?: number;
|
|
487
|
-
signal?: AbortSignal;
|
|
488
|
-
openUrl?: (url: string) => void | Promise<void>;
|
|
489
|
-
}
|
|
490
|
-
type RestoreResult = {
|
|
491
|
-
state: 'complete';
|
|
492
|
-
entitlement: Entitlement;
|
|
493
|
-
} | {
|
|
494
|
-
state: 'timeout' | 'expired' | 'canceled';
|
|
495
|
-
};
|
|
496
|
-
interface CustomerPortalOptions {
|
|
497
|
-
openUrl?: (url: string) => void | Promise<void>;
|
|
498
|
-
/** Return a listed profile ID, or null to cancel. Required by Lite for multiple profiles. */
|
|
499
|
-
selectAccount?: (accounts: PayPortalAccount[]) => string | null | Promise<string | null>;
|
|
500
|
-
}
|
|
501
|
-
interface LicenseSummary {
|
|
502
|
-
projectName: string | null;
|
|
503
|
-
seller: PaySellerPublic | null;
|
|
504
|
-
entitlement: Entitlement;
|
|
505
|
-
recoveryEnabled: boolean;
|
|
506
|
-
}
|
|
507
|
-
|
|
508
582
|
interface ExtenshiPayEvents {
|
|
509
583
|
ready: {
|
|
510
584
|
endUserRef: string;
|
|
@@ -661,6 +735,8 @@ declare const EMPTY_ENTITLEMENT: Entitlement;
|
|
|
661
735
|
declare function createRecoveryStorage(): StorageAdapter;
|
|
662
736
|
interface RecoveryManagerOptions {
|
|
663
737
|
api: PayApi;
|
|
738
|
+
/** The user's language, for the hosted recovery page and its email. */
|
|
739
|
+
locale?: string | null;
|
|
664
740
|
storage: StorageAdapter;
|
|
665
741
|
publishableKey: string;
|
|
666
742
|
onComplete: (endUserRef: string, envelope: SignedEntitlement) => Promise<Entitlement>;
|
|
@@ -709,7 +785,7 @@ declare class Logger {
|
|
|
709
785
|
declare const logger: Logger;
|
|
710
786
|
|
|
711
787
|
/** Kept in sync with package.json by tests/unit/version.test.ts. */
|
|
712
|
-
declare const VERSION = "0.
|
|
788
|
+
declare const VERSION = "0.8.0";
|
|
713
789
|
|
|
714
790
|
/** Same shape the BFF accepts (`en`, `de-DE`, `zh-Hant`). */
|
|
715
791
|
declare const LOCALE_RE: RegExp;
|
|
@@ -746,7 +822,7 @@ interface ExtenshiPayDeps {
|
|
|
746
822
|
now?: () => number;
|
|
747
823
|
}
|
|
748
824
|
declare class ExtenshiPayLite {
|
|
749
|
-
static readonly version = "0.
|
|
825
|
+
static readonly version = "0.8.0";
|
|
750
826
|
protected readonly config: ResolvedConfig;
|
|
751
827
|
protected readonly emitter: EventEmitter<ExtenshiPayEvents>;
|
|
752
828
|
protected readonly storage: StorageAdapter;
|
|
@@ -783,7 +859,26 @@ declare class ExtenshiPayLite {
|
|
|
783
859
|
requireFeature(feature: string, options?: RequireFeatureOptions): Promise<boolean>;
|
|
784
860
|
/** Lite has no UI: a locked feature stays locked. The full SDK shows the paywall here. */
|
|
785
861
|
protected onFeatureLocked(_feature: string, _options: RequireFeatureOptions): Promise<boolean>;
|
|
786
|
-
/**
|
|
862
|
+
/**
|
|
863
|
+
* The withdrawal waiver this offer asks for, with the exact text to show
|
|
864
|
+
* next to an unticked checkbox (buyer's language, seller's name filled in),
|
|
865
|
+
* or null when the seller attested the extension is not distributed in the
|
|
866
|
+
* EEA/UK. For UIs that call `openCheckout()` themselves — Lite, or a custom
|
|
867
|
+
* paywall; the full SDK's paywall does this for you.
|
|
868
|
+
*/
|
|
869
|
+
getWithdrawalWaiver(): Promise<{
|
|
870
|
+
version: string;
|
|
871
|
+
text: string;
|
|
872
|
+
} | null>;
|
|
873
|
+
/**
|
|
874
|
+
* Opens hosted checkout for `sku` in a new tab and resolves when the session settles.
|
|
875
|
+
*
|
|
876
|
+
* Called directly (not from the paywall), this does NOT collect the EU/UK
|
|
877
|
+
* withdrawal waiver. If `getWithdrawalWaiver()` returns one, your UI must
|
|
878
|
+
* collect the buyer's consent and pass it as `options.withdrawalWaiver`;
|
|
879
|
+
* without it this rejects with `WITHDRAWAL_WAIVER_REQUIRED` (the server
|
|
880
|
+
* refuses such a checkout too).
|
|
881
|
+
*/
|
|
787
882
|
openCheckout(sku: string, options?: CheckoutOptions): Promise<CheckoutResult>;
|
|
788
883
|
/** Opens email verification on the hosted page. No email is collected inside the extension. */
|
|
789
884
|
restorePurchase(options?: RestoreOptions): Promise<RestoreResult>;
|
|
@@ -817,5 +912,5 @@ declare const END_USER_REF_STORAGE_KEY = "extenshi-pay:endUserRef";
|
|
|
817
912
|
declare function mintEndUserRef(): string;
|
|
818
913
|
declare function getOrCreateEndUserRef(storage: StorageAdapter): Promise<string>;
|
|
819
914
|
|
|
820
|
-
export { CHECKOUT_POLL_INTERVAL_MS, CHECKOUT_TIMEOUT_MS, CheckoutManager, DEFAULT_API_URL, DEFAULT_CACHE_TTL_MS, EMPTY_ENTITLEMENT, END_USER_REF_STORAGE_KEY, ERROR_CODES, EntitlementManager, EventEmitter, ExtenshiPayError, ExtenshiPayLite, ExtensionStorage, HttpTransport, LOCALE_RE, LocalStorageAdapter, Logger, MAX_CACHE_TTL_MS, MAX_REFRESH_BACKOFF_MS, MIN_REFRESH_INTERVAL_MS, MemoryStorage, MockTransport, PAY_CONTRACT_VERSION, PAY_CURRENCIES, PAY_END_USER_REF_RE, PAY_ENTITLEMENT_STATUSES, PAY_ERRORS, PAY_GATEWAYS, PAY_OFFER_INTERVALS, PAY_OFFER_KINDS, PAY_PUBLISHABLE_KEY_HEX_LENGTH, PAY_PUBLISHABLE_KEY_PREFIX, PAY_SKU_RE, PayApi, RecoveryManager, TRPC_PATH, VERSION, applyLocalExpiry, base64ToBytes, canonicalJson, checkFeatures, collectFeatures, createRecoveryStorage, createStorage, getOrCreateEndUserRef, hasFeature, isEntitled, isLive, isPayPublishableKey, logger, mintEndUserRef, openInNewTab, resolveConfig, trpcErrorToPayError, verifyEntitlementSignature };
|
|
821
|
-
export type { CheckoutManagerOptions, CheckoutOptions, CheckoutResult, CheckoutState, CustomerPortalOptions, Entitlement, EntitlementManagerOptions, EntitlementSource, Environment, ErrorCode, ExtenshiPayConfig, ExtenshiPayDeps, ExtenshiPayErrorOptions, ExtenshiPayEventName, ExtenshiPayEvents, GetEntitlementOptions, HttpTransportOptions, LicenseSummary, Listener, LogLevel, MockData, PayCheckoutClaim, PayCheckoutSession, PayCurrency, PayEntitlementItem, PayEntitlementPayload, PayEntitlementStatus, PayErrorCode, PayGatewayId, PayOfferDto, PayOfferInterval, PayOfferKind, PayOfferResponse, PayPortalAccount, PayPortalResponse, PayRestoreClaimResponse, PayRestoreSessionResponse, PaySellerPublic, PaywallMode, PaywallOptions, PaywallStrings, ProcedureKind, RecoveryManagerOptions, RequireFeatureOptions, ResolvedConfig, RestoreOptions, RestoreResult, SignatureVerdict, SignedEntitlement, StorageAdapter, ThemeConfig, Transport };
|
|
915
|
+
export { CHECKOUT_POLL_INTERVAL_MS, CHECKOUT_TIMEOUT_MS, CheckoutManager, DEFAULT_API_URL, DEFAULT_CACHE_TTL_MS, EMPTY_ENTITLEMENT, END_USER_REF_STORAGE_KEY, ERROR_CODES, EntitlementManager, EventEmitter, ExtenshiPayError, ExtenshiPayLite, ExtensionStorage, HttpTransport, LOCALE_RE, LocalStorageAdapter, Logger, MAX_CACHE_TTL_MS, MAX_REFRESH_BACKOFF_MS, MIN_REFRESH_INTERVAL_MS, MemoryStorage, MockTransport, PAY_CONTRACT_VERSION, PAY_CURRENCIES, PAY_END_USER_REF_RE, PAY_ENTITLEMENT_STATUSES, PAY_ERRORS, PAY_GATEWAYS, PAY_OFFER_INTERVALS, PAY_OFFER_KINDS, PAY_PUBLISHABLE_KEY_HEX_LENGTH, PAY_PUBLISHABLE_KEY_PREFIX, PAY_SKU_RE, PAY_WITHDRAWAL_WAIVER_VERSION, PayApi, RecoveryManager, TRPC_PATH, VERSION, applyLocalExpiry, base64ToBytes, canonicalJson, checkFeatures, collectFeatures, createRecoveryStorage, createStorage, getOrCreateEndUserRef, hasFeature, isEntitled, isLive, isPayPublishableKey, logger, mintEndUserRef, openInNewTab, resolveConfig, trpcErrorToPayError, verifyEntitlementSignature };
|
|
916
|
+
export type { CheckoutManagerOptions, CheckoutOptions, CheckoutResult, CheckoutState, CustomerPortalOptions, Entitlement, EntitlementManagerOptions, EntitlementSource, Environment, ErrorCode, ExtenshiPayConfig, ExtenshiPayDeps, ExtenshiPayErrorOptions, ExtenshiPayEventName, ExtenshiPayEvents, GetEntitlementOptions, HttpTransportOptions, LicenseSummary, Listener, LogLevel, MockData, PayCheckoutClaim, PayCheckoutSession, PayCurrency, PayEntitlementItem, PayEntitlementPayload, PayEntitlementStatus, PayErrorCode, PayGatewayId, PayOfferDto, PayOfferInterval, PayOfferKind, PayOfferResponse, PayPortalAccount, PayPortalResponse, PayRestoreClaimResponse, PayRestoreSessionResponse, PaySellerPublic, PayWithdrawalWaiver, PaywallMode, PaywallOptions, PaywallStrings, ProcedureKind, RecoveryManagerOptions, RequireFeatureOptions, ResolvedConfig, RestoreOptions, RestoreResult, SignatureVerdict, SignedEntitlement, StorageAdapter, ThemeConfig, Transport, UpgradeConsent, WithdrawalWaiverConsent };
|