@extenshi/pay 0.7.1 → 0.9.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 +16 -10
- 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 +219 -113
- package/dist/core.d.ts +219 -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 +1386 -191
- package/dist/extenshi-pay.cjs.js.map +1 -1
- package/dist/extenshi-pay.d.ts.map +1 -1
- package/dist/extenshi-pay.js +1386 -191
- 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 +1383 -192
- package/dist/extenshi-pay.mjs.map +1 -1
- package/dist/index.d.mts +287 -117
- package/dist/index.d.ts +287 -117
- package/dist/lite.d.mts +188 -83
- package/dist/lite.d.ts +188 -83
- 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/icon.d.ts +18 -0
- package/dist/paywall/icon.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 +24 -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 +113 -8
- package/dist/paywall.d.ts +113 -8
- package/dist/paywall.js +1068 -51
- package/dist/paywall.js.map +1 -1
- package/dist/paywall.mjs +1066 -52
- 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 +27 -3
- package/dist/types/paywall.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +2 -2
- 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/dist/index.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,156 @@ 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
|
+
/**
|
|
331
|
+
* Bullet points, in the user's language (`chrome.i18n.getMessage`). The
|
|
332
|
+
* offer's `features[]` are entitlement keys and are never shown: without
|
|
333
|
+
* this option the paywall has no feature list.
|
|
334
|
+
*/
|
|
335
|
+
features?: string[];
|
|
336
|
+
/** Free-tier bullets for the comparison templates (`inline`, `fullscreen`). */
|
|
337
|
+
freeFeatures?: string[];
|
|
338
|
+
/**
|
|
339
|
+
* Header image in place of the template's glyph: a path inside the
|
|
340
|
+
* extension (`icons/icon128.png`) or a `data:image/` URL. Defaults to the
|
|
341
|
+
* largest `manifest.icons` entry on the extension's own pages (popup,
|
|
342
|
+
* options); `false` keeps the glyph. Remote URLs are ignored.
|
|
343
|
+
*/
|
|
344
|
+
icon?: string | false;
|
|
345
|
+
theme?: ThemeConfig;
|
|
346
|
+
/** Mount point for `inline` mode (default `document.body`). */
|
|
347
|
+
container?: HTMLElement;
|
|
348
|
+
strings?: Partial<PaywallStrings>;
|
|
349
|
+
/** `consent` carries the withdrawal waiver when the paywall showed one. */
|
|
350
|
+
onUpgrade?: (sku: string, consent?: UpgradeConsent) => void;
|
|
351
|
+
onClose?: () => void;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
type EntitlementSource = 'network' | 'cache' | 'mock' | 'none';
|
|
355
|
+
/** The SDK's view of the server projection, with `expiresAt` applied locally. */
|
|
356
|
+
interface Entitlement {
|
|
357
|
+
items: PayEntitlementItem[];
|
|
358
|
+
/** Union of `features[]` over active/grace items. */
|
|
359
|
+
features: string[];
|
|
360
|
+
/** True only when the Ed25519 signature was checked against the project's key. */
|
|
361
|
+
verified: boolean;
|
|
362
|
+
issuedAt: string | null;
|
|
363
|
+
/** `Date.now()` of the last successful fetch, or null when nothing was ever fetched. */
|
|
364
|
+
fetchedAt: number | null;
|
|
365
|
+
/** Paid access is paused until a successful online check, not a license expiry. */
|
|
366
|
+
requiresOnlineCheck?: boolean;
|
|
367
|
+
/** Local offline-access deadline; null for mock mode or no cached license. */
|
|
368
|
+
offlineUntil?: number | null;
|
|
369
|
+
source: EntitlementSource;
|
|
370
|
+
}
|
|
371
|
+
interface GetEntitlementOptions {
|
|
372
|
+
/** Skip the cache TTL and hit the network. */
|
|
373
|
+
force?: boolean;
|
|
374
|
+
}
|
|
375
|
+
type CheckoutState = 'complete' | 'canceled' | 'expired' | 'timeout';
|
|
376
|
+
interface CheckoutResult {
|
|
377
|
+
state: CheckoutState;
|
|
378
|
+
sku: string;
|
|
379
|
+
sessionId: string;
|
|
380
|
+
entitlement?: Entitlement;
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* The buyer ticked the withdrawal-waiver checkbox (EU/EEA/UK digital content).
|
|
384
|
+
* `version` names the waiver words that were shown (`PAY_WITHDRAWAL_WAIVER_VERSION`).
|
|
385
|
+
*/
|
|
386
|
+
interface WithdrawalWaiverConsent {
|
|
387
|
+
version: string;
|
|
388
|
+
accepted: true;
|
|
389
|
+
}
|
|
390
|
+
/** What a paywall upgrade click carries besides the SKU. */
|
|
391
|
+
interface UpgradeConsent {
|
|
392
|
+
withdrawalWaiver?: WithdrawalWaiverConsent;
|
|
393
|
+
}
|
|
394
|
+
interface CheckoutOptions {
|
|
395
|
+
locale?: string;
|
|
396
|
+
/**
|
|
397
|
+
* Withdrawal-waiver consent, sent with `pay.createCheckout`. The paywall
|
|
398
|
+
* collects it itself. When you call `openCheckout()` from your own UI, ask
|
|
399
|
+
* `getWithdrawalWaiver()` first: if it returns a waiver, YOUR UI must show an
|
|
400
|
+
* unticked checkbox with exactly its `text` and pass
|
|
401
|
+
* `{ version, accepted: true }` here only once the buyer ticked it. Without
|
|
402
|
+
* it `openCheckout()` rejects with `WITHDRAWAL_WAIVER_REQUIRED`, and so does
|
|
403
|
+
* the server.
|
|
404
|
+
*/
|
|
405
|
+
withdrawalWaiver?: WithdrawalWaiverConsent;
|
|
406
|
+
/** Stop polling `claimSession` after this long (default 10 minutes). */
|
|
407
|
+
timeoutMs?: number;
|
|
408
|
+
/** Poll interval (default 2 seconds). */
|
|
409
|
+
pollIntervalMs?: number;
|
|
410
|
+
/** Override how the hosted checkout URL is opened (default: `chrome.tabs.create`, then `window.open`). */
|
|
411
|
+
openUrl?: (url: string) => void | Promise<void>;
|
|
412
|
+
}
|
|
413
|
+
interface RequireFeatureOptions {
|
|
414
|
+
/** Full bundle only: show the paywall when the feature is locked (default true). */
|
|
415
|
+
showPaywall?: boolean;
|
|
416
|
+
onUnlock?: () => void;
|
|
417
|
+
onCancel?: () => void;
|
|
418
|
+
/** Paywall options used when `showPaywall` is true. */
|
|
419
|
+
paywall?: PaywallOptions;
|
|
420
|
+
}
|
|
421
|
+
interface RestoreOptions {
|
|
422
|
+
timeoutMs?: number;
|
|
423
|
+
pollIntervalMs?: number;
|
|
424
|
+
signal?: AbortSignal;
|
|
425
|
+
openUrl?: (url: string) => void | Promise<void>;
|
|
426
|
+
}
|
|
427
|
+
type RestoreResult = {
|
|
428
|
+
state: 'complete';
|
|
429
|
+
entitlement: Entitlement;
|
|
430
|
+
} | {
|
|
431
|
+
state: 'timeout' | 'expired' | 'canceled';
|
|
432
|
+
};
|
|
433
|
+
interface CustomerPortalOptions {
|
|
434
|
+
openUrl?: (url: string) => void | Promise<void>;
|
|
435
|
+
/** Return a listed profile ID, or null to cancel. Required by Lite for multiple profiles. */
|
|
436
|
+
selectAccount?: (accounts: PayPortalAccount[]) => string | null | Promise<string | null>;
|
|
437
|
+
}
|
|
438
|
+
interface LicenseSummary {
|
|
439
|
+
projectName: string | null;
|
|
440
|
+
seller: PaySellerPublic | null;
|
|
441
|
+
entitlement: Entitlement;
|
|
442
|
+
recoveryEnabled: boolean;
|
|
443
|
+
}
|
|
444
|
+
|
|
264
445
|
/**
|
|
265
446
|
* HTTP transport for the BFF's tRPC endpoint (`/api/trpc/<procedure>`).
|
|
266
447
|
*
|
|
@@ -323,6 +504,8 @@ interface MockSession {
|
|
|
323
504
|
sku: string;
|
|
324
505
|
polls: number;
|
|
325
506
|
state: SessionState;
|
|
507
|
+
/** What `createCheckout` received, for inspecting the consent in dev/tests. */
|
|
508
|
+
withdrawalWaiver: WithdrawalWaiverConsent | null;
|
|
326
509
|
}
|
|
327
510
|
declare class MockTransport implements Transport {
|
|
328
511
|
private entitlements;
|
|
@@ -330,6 +513,7 @@ declare class MockTransport implements Transport {
|
|
|
330
513
|
private readonly projectName;
|
|
331
514
|
private readonly checkoutEnabled;
|
|
332
515
|
private readonly claimAfterPolls;
|
|
516
|
+
private readonly withdrawalWaiver;
|
|
333
517
|
readonly sessions: Map<string, MockSession>;
|
|
334
518
|
constructor(data?: MockData);
|
|
335
519
|
call<T>(procedure: string, _kind: ProcedureKind, input: Record<string, unknown>): Promise<T>;
|
|
@@ -350,13 +534,19 @@ declare class PayApi {
|
|
|
350
534
|
private readonly transport;
|
|
351
535
|
private readonly publishableKey;
|
|
352
536
|
constructor(transport: Transport, publishableKey: string);
|
|
353
|
-
|
|
537
|
+
/** `locale` opens the hosted recovery page (and its email) in the user's language. */
|
|
538
|
+
createRestoreSession(claimChallenge: string, locale?: string | null): Promise<PayRestoreSessionResponse>;
|
|
354
539
|
claimRestoreSession(sessionId: string, claimSecret: string): Promise<PayRestoreClaimResponse>;
|
|
355
540
|
getOffer(locale?: string | null): Promise<PayOfferResponse>;
|
|
356
|
-
|
|
541
|
+
/**
|
|
542
|
+
* `withdrawalWaiver` is sent only when given. Older BFFs parse the input with
|
|
543
|
+
* a non-strict zod object, which strips the unknown key, so it is safe there.
|
|
544
|
+
* Plain-JS callers passing anything but `accepted: true` send no consent.
|
|
545
|
+
*/
|
|
546
|
+
createCheckout(sku: string, endUserRef: string, locale?: string | null, withdrawalWaiver?: WithdrawalWaiverConsent): Promise<PayCheckoutSession>;
|
|
357
547
|
claimSession(sessionId: string, endUserRef: string): Promise<PayCheckoutClaim>;
|
|
358
548
|
getEntitlement(endUserRef: string): Promise<SignedEntitlement>;
|
|
359
|
-
getPortalUrl(endUserRef: string, customerId?: string): Promise<PayPortalResponse>;
|
|
549
|
+
getPortalUrl(endUserRef: string, customerId?: string, locale?: string | null): Promise<PayPortalResponse>;
|
|
360
550
|
}
|
|
361
551
|
|
|
362
552
|
/**
|
|
@@ -400,111 +590,6 @@ declare class MemoryStorage implements StorageAdapter {
|
|
|
400
590
|
}
|
|
401
591
|
declare function createStorage(): StorageAdapter;
|
|
402
592
|
|
|
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
593
|
interface ExtenshiPayEvents {
|
|
509
594
|
ready: {
|
|
510
595
|
endUserRef: string;
|
|
@@ -661,6 +746,8 @@ declare const EMPTY_ENTITLEMENT: Entitlement;
|
|
|
661
746
|
declare function createRecoveryStorage(): StorageAdapter;
|
|
662
747
|
interface RecoveryManagerOptions {
|
|
663
748
|
api: PayApi;
|
|
749
|
+
/** The user's language, for the hosted recovery page and its email. */
|
|
750
|
+
locale?: string | null;
|
|
664
751
|
storage: StorageAdapter;
|
|
665
752
|
publishableKey: string;
|
|
666
753
|
onComplete: (endUserRef: string, envelope: SignedEntitlement) => Promise<Entitlement>;
|
|
@@ -709,7 +796,7 @@ declare class Logger {
|
|
|
709
796
|
declare const logger: Logger;
|
|
710
797
|
|
|
711
798
|
/** Kept in sync with package.json by tests/unit/version.test.ts. */
|
|
712
|
-
declare const VERSION = "0.
|
|
799
|
+
declare const VERSION = "0.9.0";
|
|
713
800
|
|
|
714
801
|
/** Same shape the BFF accepts (`en`, `de-DE`, `zh-Hant`). */
|
|
715
802
|
declare const LOCALE_RE: RegExp;
|
|
@@ -746,7 +833,7 @@ interface ExtenshiPayDeps {
|
|
|
746
833
|
now?: () => number;
|
|
747
834
|
}
|
|
748
835
|
declare class ExtenshiPayLite {
|
|
749
|
-
static readonly version = "0.
|
|
836
|
+
static readonly version = "0.9.0";
|
|
750
837
|
protected readonly config: ResolvedConfig;
|
|
751
838
|
protected readonly emitter: EventEmitter<ExtenshiPayEvents>;
|
|
752
839
|
protected readonly storage: StorageAdapter;
|
|
@@ -783,7 +870,26 @@ declare class ExtenshiPayLite {
|
|
|
783
870
|
requireFeature(feature: string, options?: RequireFeatureOptions): Promise<boolean>;
|
|
784
871
|
/** Lite has no UI: a locked feature stays locked. The full SDK shows the paywall here. */
|
|
785
872
|
protected onFeatureLocked(_feature: string, _options: RequireFeatureOptions): Promise<boolean>;
|
|
786
|
-
/**
|
|
873
|
+
/**
|
|
874
|
+
* The withdrawal waiver this offer asks for, with the exact text to show
|
|
875
|
+
* next to an unticked checkbox (buyer's language, seller's name filled in),
|
|
876
|
+
* or null when the seller attested the extension is not distributed in the
|
|
877
|
+
* EEA/UK. For UIs that call `openCheckout()` themselves — Lite, or a custom
|
|
878
|
+
* paywall; the full SDK's paywall does this for you.
|
|
879
|
+
*/
|
|
880
|
+
getWithdrawalWaiver(): Promise<{
|
|
881
|
+
version: string;
|
|
882
|
+
text: string;
|
|
883
|
+
} | null>;
|
|
884
|
+
/**
|
|
885
|
+
* Opens hosted checkout for `sku` in a new tab and resolves when the session settles.
|
|
886
|
+
*
|
|
887
|
+
* Called directly (not from the paywall), this does NOT collect the EU/UK
|
|
888
|
+
* withdrawal waiver. If `getWithdrawalWaiver()` returns one, your UI must
|
|
889
|
+
* collect the buyer's consent and pass it as `options.withdrawalWaiver`;
|
|
890
|
+
* without it this rejects with `WITHDRAWAL_WAIVER_REQUIRED` (the server
|
|
891
|
+
* refuses such a checkout too).
|
|
892
|
+
*/
|
|
787
893
|
openCheckout(sku: string, options?: CheckoutOptions): Promise<CheckoutResult>;
|
|
788
894
|
/** Opens email verification on the hosted page. No email is collected inside the extension. */
|
|
789
895
|
restorePurchase(options?: RestoreOptions): Promise<RestoreResult>;
|
|
@@ -846,6 +952,49 @@ declare class ExtenshiPay extends ExtenshiPayLite {
|
|
|
846
952
|
private settlePaywall;
|
|
847
953
|
}
|
|
848
954
|
|
|
955
|
+
/**
|
|
956
|
+
* Every string the SDK shows to the USER of an extension — paywall, license
|
|
957
|
+
* dialog, billing-profile picker, seller details — in the end-user languages
|
|
958
|
+
* (ROADMAP it. 13 T10, stage L2; closes it. 12 T9). Developer-facing error
|
|
959
|
+
* messages stay English.
|
|
960
|
+
*
|
|
961
|
+
* Self-contained on purpose: the SDK ships inside third-party extensions with
|
|
962
|
+
* no runtime dependencies and no remote code, so the dictionary is compiled
|
|
963
|
+
* in. Placeholders are `{name}`, `{date}`, `{status}`. A missing
|
|
964
|
+
* translation falls back to English, never to an empty string. The same
|
|
965
|
+
* languages as the hosted pages (shared-types END_USER_LOCALES); keep the
|
|
966
|
+
* lists in sync.
|
|
967
|
+
*/
|
|
968
|
+
|
|
969
|
+
declare const SDK_LOCALES: readonly ["en", "es", "pt-BR", "fr", "de", "it", "ru", "ja", "ko", "zh-CN", "ar"];
|
|
970
|
+
type SdkLocale = (typeof SDK_LOCALES)[number];
|
|
971
|
+
|
|
972
|
+
/**
|
|
973
|
+
* Buyer-facing withdrawal-waiver text (EU/EEA digital content, Directive
|
|
974
|
+
* 2011/83/EU art. 16(m); UK CCR 2013 reg. 37), per text version and SDK
|
|
975
|
+
* language. Its own module, not part of the paywall dictionary, so Lite can
|
|
976
|
+
* show it without bundling every paywall string.
|
|
977
|
+
*
|
|
978
|
+
* The recorded consent names the version, so a version's words never change:
|
|
979
|
+
* new wording is a new version here and a new PAY_WITHDRAWAL_WAIVER_VERSION.
|
|
980
|
+
*
|
|
981
|
+
* MIRRORED in shared-types/pay-withdrawal-waiver.ts, which the purchase
|
|
982
|
+
* confirmation email quotes; shared-types/pay-withdrawal-waiver.test.ts fails
|
|
983
|
+
* unless both copies are byte-identical. Change them together.
|
|
984
|
+
*/
|
|
985
|
+
|
|
986
|
+
declare const WITHDRAWAL_WAIVER_TEXTS: Readonly<Record<string, Readonly<Record<SdkLocale, string>>>>;
|
|
987
|
+
/**
|
|
988
|
+
* The waiver text to show for `serverVersion`, and the version to send with
|
|
989
|
+
* the consent. A version this SDK does not know (a newer server) shows this
|
|
990
|
+
* SDK's current text and sends its version: the consent always names the words
|
|
991
|
+
* actually shown.
|
|
992
|
+
*/
|
|
993
|
+
declare function withdrawalWaiverText(serverVersion: string, locale: string | null | undefined, seller: string): {
|
|
994
|
+
version: string;
|
|
995
|
+
text: string;
|
|
996
|
+
};
|
|
997
|
+
|
|
849
998
|
interface FormattedPrice {
|
|
850
999
|
/** Currency symbol/code as the locale renders it (`$`, `€`, `US$`). */
|
|
851
1000
|
currency: string;
|
|
@@ -873,23 +1022,33 @@ interface PaywallView {
|
|
|
873
1022
|
description: string;
|
|
874
1023
|
features: string[];
|
|
875
1024
|
freeFeatures: string[];
|
|
1025
|
+
/** Header image URL (./icon.ts) in place of the template's glyph; absent or null keeps the glyph. */
|
|
1026
|
+
icon?: string | null;
|
|
876
1027
|
brandName: string;
|
|
877
1028
|
offer: PayOfferDto | null;
|
|
878
1029
|
checkoutEnabled: boolean;
|
|
879
1030
|
mock?: boolean;
|
|
880
1031
|
recoveryEnabled?: boolean;
|
|
881
1032
|
seller?: PaySellerPublic | null;
|
|
1033
|
+
/**
|
|
1034
|
+
* From `PayOfferResponse.withdrawalWaiver`: when set (and the offer is
|
|
1035
|
+
* purchasable) an unticked waiver checkbox gates every upgrade button.
|
|
1036
|
+
* The waiver text is not overridable through `strings`: it is versioned.
|
|
1037
|
+
*/
|
|
1038
|
+
withdrawalWaiver?: PayWithdrawalWaiver | null;
|
|
882
1039
|
locale: string | null;
|
|
883
1040
|
theme: ThemeConfig;
|
|
884
1041
|
strings: Partial<PaywallStrings>;
|
|
885
1042
|
container?: HTMLElement;
|
|
886
1043
|
}
|
|
887
1044
|
interface PaywallRendererCallbacks {
|
|
888
|
-
|
|
1045
|
+
/** `consent` is passed only when the paywall showed the withdrawal waiver (and it was ticked). */
|
|
1046
|
+
onUpgrade: (sku: string, consent?: UpgradeConsent) => void;
|
|
889
1047
|
onClose: () => void;
|
|
890
1048
|
onRestore?: () => void;
|
|
891
1049
|
}
|
|
892
1050
|
declare const PAYWALL_HOST_CLASS = "extenshi-paywall-host";
|
|
1051
|
+
declare const WITHDRAWAL_WAIVER_CLASS = "extenshi-withdrawal-waiver";
|
|
893
1052
|
declare function escapeHtml(value: string): string;
|
|
894
1053
|
declare function substitute(html: string, content: Record<string, string>): string;
|
|
895
1054
|
declare function buildContent(view: PaywallView, strings: PaywallStrings): Record<string, string>;
|
|
@@ -905,18 +1064,29 @@ declare class PaywallRenderer {
|
|
|
905
1064
|
show(view: PaywallView): HTMLElement;
|
|
906
1065
|
hide(): void;
|
|
907
1066
|
private prune;
|
|
1067
|
+
/**
|
|
1068
|
+
* Swaps the templates' product glyphs for the extension's icon. A tile's
|
|
1069
|
+
* gradient only backs the white glyph, so it goes too; an image that fails
|
|
1070
|
+
* to load puts the glyph (and the gradient) back.
|
|
1071
|
+
*/
|
|
1072
|
+
private placeIcon;
|
|
1073
|
+
/**
|
|
1074
|
+
* Inserts the unticked waiver checkbox right before the first upgrade
|
|
1075
|
+
* button and keeps every upgrade button disabled until it is ticked.
|
|
1076
|
+
*/
|
|
1077
|
+
private mountWaiver;
|
|
908
1078
|
private bind;
|
|
909
1079
|
private reveal;
|
|
910
1080
|
private close;
|
|
911
1081
|
}
|
|
912
1082
|
|
|
913
1083
|
/**
|
|
914
|
-
*
|
|
915
|
-
*
|
|
916
|
-
* promotional claims here without marketing/legal review (see
|
|
1084
|
+
* The paywall's strings in a locale, from the SDK dictionary (./i18n.ts).
|
|
1085
|
+
* Do not add promotional claims without marketing/legal review (see
|
|
917
1086
|
* .claude/modules/paywall-templates.md).
|
|
918
1087
|
*/
|
|
919
1088
|
|
|
1089
|
+
/** English (the default and the fallback). */
|
|
920
1090
|
declare const DEFAULT_STRINGS: PaywallStrings;
|
|
921
1091
|
|
|
922
1092
|
/**
|
|
@@ -933,5 +1103,5 @@ declare const PAYWALL_SHARED_CSS: string;
|
|
|
933
1103
|
declare const PAYWALL_TEMPLATES: Record<PaywallMode, PaywallTemplate>;
|
|
934
1104
|
declare const PAYWALL_MODES: PaywallMode[];
|
|
935
1105
|
|
|
936
|
-
export { CHECKOUT_POLL_INTERVAL_MS, CHECKOUT_TIMEOUT_MS, CheckoutManager, DEFAULT_API_URL, DEFAULT_CACHE_TTL_MS, DEFAULT_STRINGS, EMPTY_ENTITLEMENT, END_USER_REF_STORAGE_KEY, ERROR_CODES, EntitlementManager, EventEmitter, ExtenshiPay, ExtenshiPayError, ExtenshiPayLite, ExtensionStorage, HttpTransport, LOCALE_RE, LocalStorageAdapter, Logger, MAX_CACHE_TTL_MS, MAX_REFRESH_BACKOFF_MS, MIN_REFRESH_INTERVAL_MS, MemoryStorage, MockTransport, PAYWALL_HOST_CLASS, PAYWALL_MODES, PAYWALL_SHARED_CSS, PAYWALL_TEMPLATES, 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, PaywallRenderer, RecoveryManager, TRPC_PATH, VERSION, applyLocalExpiry, base64ToBytes, buildContent, canonicalJson, checkFeatures, collectFeatures, createRecoveryStorage, createStorage, ExtenshiPay as default, escapeHtml, formatPrice, getOrCreateEndUserRef, hasFeature, isEntitled, isLive, isPayPublishableKey, logger, mintEndUserRef, openInNewTab, periodLabel, resolveConfig, resolveThemeMode, substitute, themeCss, trpcErrorToPayError, verifyEntitlementSignature };
|
|
937
|
-
export type { CheckoutManagerOptions, CheckoutOptions, CheckoutResult, CheckoutState, CustomerPortalOptions, Entitlement, EntitlementManagerOptions, EntitlementSource, Environment, ErrorCode, ExtenshiPayConfig, ExtenshiPayDeps, ExtenshiPayErrorOptions, ExtenshiPayEventName, ExtenshiPayEvents, FormattedPrice, 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, PaywallRendererCallbacks, PaywallStrings, PaywallTemplate, PaywallView, ProcedureKind, RecoveryManagerOptions, RequireFeatureOptions, ResolvedConfig, RestoreOptions, RestoreResult, SignatureVerdict, SignedEntitlement, StorageAdapter, ThemeConfig, Transport };
|
|
1106
|
+
export { CHECKOUT_POLL_INTERVAL_MS, CHECKOUT_TIMEOUT_MS, CheckoutManager, DEFAULT_API_URL, DEFAULT_CACHE_TTL_MS, DEFAULT_STRINGS, EMPTY_ENTITLEMENT, END_USER_REF_STORAGE_KEY, ERROR_CODES, EntitlementManager, EventEmitter, ExtenshiPay, ExtenshiPayError, ExtenshiPayLite, ExtensionStorage, HttpTransport, LOCALE_RE, LocalStorageAdapter, Logger, MAX_CACHE_TTL_MS, MAX_REFRESH_BACKOFF_MS, MIN_REFRESH_INTERVAL_MS, MemoryStorage, MockTransport, PAYWALL_HOST_CLASS, PAYWALL_MODES, PAYWALL_SHARED_CSS, PAYWALL_TEMPLATES, 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, PaywallRenderer, RecoveryManager, TRPC_PATH, VERSION, WITHDRAWAL_WAIVER_CLASS, WITHDRAWAL_WAIVER_TEXTS, applyLocalExpiry, base64ToBytes, buildContent, canonicalJson, checkFeatures, collectFeatures, createRecoveryStorage, createStorage, ExtenshiPay as default, escapeHtml, formatPrice, getOrCreateEndUserRef, hasFeature, isEntitled, isLive, isPayPublishableKey, logger, mintEndUserRef, openInNewTab, periodLabel, resolveConfig, resolveThemeMode, substitute, themeCss, trpcErrorToPayError, verifyEntitlementSignature, withdrawalWaiverText };
|
|
1107
|
+
export type { CheckoutManagerOptions, CheckoutOptions, CheckoutResult, CheckoutState, CustomerPortalOptions, Entitlement, EntitlementManagerOptions, EntitlementSource, Environment, ErrorCode, ExtenshiPayConfig, ExtenshiPayDeps, ExtenshiPayErrorOptions, ExtenshiPayEventName, ExtenshiPayEvents, FormattedPrice, 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, PaywallRendererCallbacks, PaywallStrings, PaywallTemplate, PaywallView, ProcedureKind, RecoveryManagerOptions, RequireFeatureOptions, ResolvedConfig, RestoreOptions, RestoreResult, SignatureVerdict, SignedEntitlement, StorageAdapter, ThemeConfig, Transport, UpgradeConsent, WithdrawalWaiverConsent };
|