@extenshi/pay 0.7.1 → 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.
Files changed (86) hide show
  1. package/README.md +11 -9
  2. package/dist/api/mock.d.ts +4 -0
  3. package/dist/api/mock.d.ts.map +1 -1
  4. package/dist/api/pay-api.d.ts +10 -3
  5. package/dist/api/pay-api.d.ts.map +1 -1
  6. package/dist/api/transport.d.ts.map +1 -1
  7. package/dist/core/config.d.ts.map +1 -1
  8. package/dist/core/extenshi-pay.d.ts +21 -2
  9. package/dist/core/extenshi-pay.d.ts.map +1 -1
  10. package/dist/core/locale.d.ts +13 -0
  11. package/dist/core/locale.d.ts.map +1 -0
  12. package/dist/core.d.mts +208 -113
  13. package/dist/core.d.ts +208 -113
  14. package/dist/core.js +204 -14
  15. package/dist/core.js.map +1 -1
  16. package/dist/core.mjs +204 -15
  17. package/dist/core.mjs.map +1 -1
  18. package/dist/extenshi-pay-lite.js +204 -14
  19. package/dist/extenshi-pay-lite.js.map +1 -1
  20. package/dist/extenshi-pay-lite.min.js +3 -2
  21. package/dist/extenshi-pay-lite.min.js.map +1 -1
  22. package/dist/extenshi-pay-lite.mjs +204 -15
  23. package/dist/extenshi-pay-lite.mjs.map +1 -1
  24. package/dist/extenshi-pay.cjs.js +1234 -180
  25. package/dist/extenshi-pay.cjs.js.map +1 -1
  26. package/dist/extenshi-pay.d.ts.map +1 -1
  27. package/dist/extenshi-pay.js +1234 -180
  28. package/dist/extenshi-pay.js.map +1 -1
  29. package/dist/extenshi-pay.min.js +3 -2
  30. package/dist/extenshi-pay.min.js.map +1 -1
  31. package/dist/extenshi-pay.min.mjs +3 -2
  32. package/dist/extenshi-pay.min.mjs.map +1 -1
  33. package/dist/extenshi-pay.mjs +1231 -181
  34. package/dist/extenshi-pay.mjs.map +1 -1
  35. package/dist/index.d.mts +268 -117
  36. package/dist/index.d.ts +268 -117
  37. package/dist/lite.d.mts +176 -82
  38. package/dist/lite.d.ts +176 -82
  39. package/dist/lite.d.ts.map +1 -1
  40. package/dist/payment/checkout.d.ts.map +1 -1
  41. package/dist/payment/recovery.d.ts +2 -0
  42. package/dist/payment/recovery.d.ts.map +1 -1
  43. package/dist/payment/withdrawal-waiver.d.ts +26 -0
  44. package/dist/payment/withdrawal-waiver.d.ts.map +1 -0
  45. package/dist/paywall/billing-profile-picker.d.ts +1 -1
  46. package/dist/paywall/billing-profile-picker.d.ts.map +1 -1
  47. package/dist/paywall/i18n.d.ts +94 -0
  48. package/dist/paywall/i18n.d.ts.map +1 -0
  49. package/dist/paywall/index.d.ts +2 -1
  50. package/dist/paywall/index.d.ts.map +1 -1
  51. package/dist/paywall/license-panel.d.ts +4 -1
  52. package/dist/paywall/license-panel.d.ts.map +1 -1
  53. package/dist/paywall/renderer.d.ts +16 -2
  54. package/dist/paywall/renderer.d.ts.map +1 -1
  55. package/dist/paywall/seller-details.d.ts +2 -1
  56. package/dist/paywall/seller-details.d.ts.map +1 -1
  57. package/dist/paywall/strings.d.ts +6 -4
  58. package/dist/paywall/strings.d.ts.map +1 -1
  59. package/dist/paywall.d.mts +93 -7
  60. package/dist/paywall.d.ts +93 -7
  61. package/dist/paywall.js +992 -41
  62. package/dist/paywall.js.map +1 -1
  63. package/dist/paywall.mjs +990 -42
  64. package/dist/paywall.mjs.map +1 -1
  65. package/dist/types/config.d.ts +6 -1
  66. package/dist/types/config.d.ts.map +1 -1
  67. package/dist/types/contract.d.ts +25 -0
  68. package/dist/types/contract.d.ts.map +1 -1
  69. package/dist/types/entitlement.d.ts +22 -0
  70. package/dist/types/entitlement.d.ts.map +1 -1
  71. package/dist/types/errors.d.ts +1 -0
  72. package/dist/types/errors.d.ts.map +1 -1
  73. package/dist/types/paywall.d.ts +15 -2
  74. package/dist/types/paywall.d.ts.map +1 -1
  75. package/dist/version.d.ts +1 -1
  76. package/package.json +2 -2
  77. package/dist/core.esm.js +0 -1681
  78. package/dist/core.esm.js.map +0 -1
  79. package/dist/extenshi-pay-lite.esm.js +0 -1664
  80. package/dist/extenshi-pay-lite.esm.js.map +0 -1
  81. package/dist/extenshi-pay.esm.js +0 -2496
  82. package/dist/extenshi-pay.esm.js.map +0 -1
  83. package/dist/extenshi-pay.esm.min.js +0 -7
  84. package/dist/extenshi-pay.esm.min.js.map +0 -1
  85. package/dist/paywall.esm.js +0 -442
  86. 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,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
- createRestoreSession(claimChallenge: string): Promise<PayRestoreSessionResponse>;
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
- createCheckout(sku: string, endUserRef: string, locale?: string | null): Promise<PayCheckoutSession>;
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.7.1";
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.7.1";
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
- /** Opens hosted checkout for `sku` in a new tab and resolves when the session settles. */
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>;
@@ -846,6 +941,49 @@ declare class ExtenshiPay extends ExtenshiPayLite {
846
941
  private settlePaywall;
847
942
  }
848
943
 
944
+ /**
945
+ * Every string the SDK shows to the USER of an extension — paywall, license
946
+ * dialog, billing-profile picker, seller details — in the end-user languages
947
+ * (ROADMAP it. 13 T10, stage L2; closes it. 12 T9). Developer-facing error
948
+ * messages stay English.
949
+ *
950
+ * Self-contained on purpose: the SDK ships inside third-party extensions with
951
+ * no runtime dependencies and no remote code, so the dictionary is compiled
952
+ * in. Placeholders are `{name}`, `{date}`, `{status}`. A missing
953
+ * translation falls back to English, never to an empty string. The same
954
+ * languages as the hosted pages (shared-types END_USER_LOCALES); keep the
955
+ * lists in sync.
956
+ */
957
+
958
+ declare const SDK_LOCALES: readonly ["en", "es", "pt-BR", "fr", "de", "it", "ru", "ja", "ko", "zh-CN", "ar"];
959
+ type SdkLocale = (typeof SDK_LOCALES)[number];
960
+
961
+ /**
962
+ * Buyer-facing withdrawal-waiver text (EU/EEA digital content, Directive
963
+ * 2011/83/EU art. 16(m); UK CCR 2013 reg. 37), per text version and SDK
964
+ * language. Its own module, not part of the paywall dictionary, so Lite can
965
+ * show it without bundling every paywall string.
966
+ *
967
+ * The recorded consent names the version, so a version's words never change:
968
+ * new wording is a new version here and a new PAY_WITHDRAWAL_WAIVER_VERSION.
969
+ *
970
+ * MIRRORED in shared-types/pay-withdrawal-waiver.ts, which the purchase
971
+ * confirmation email quotes; shared-types/pay-withdrawal-waiver.test.ts fails
972
+ * unless both copies are byte-identical. Change them together.
973
+ */
974
+
975
+ declare const WITHDRAWAL_WAIVER_TEXTS: Readonly<Record<string, Readonly<Record<SdkLocale, string>>>>;
976
+ /**
977
+ * The waiver text to show for `serverVersion`, and the version to send with
978
+ * the consent. A version this SDK does not know (a newer server) shows this
979
+ * SDK's current text and sends its version: the consent always names the words
980
+ * actually shown.
981
+ */
982
+ declare function withdrawalWaiverText(serverVersion: string, locale: string | null | undefined, seller: string): {
983
+ version: string;
984
+ text: string;
985
+ };
986
+
849
987
  interface FormattedPrice {
850
988
  /** Currency symbol/code as the locale renders it (`$`, `€`, `US$`). */
851
989
  currency: string;
@@ -879,17 +1017,25 @@ interface PaywallView {
879
1017
  mock?: boolean;
880
1018
  recoveryEnabled?: boolean;
881
1019
  seller?: PaySellerPublic | null;
1020
+ /**
1021
+ * From `PayOfferResponse.withdrawalWaiver`: when set (and the offer is
1022
+ * purchasable) an unticked waiver checkbox gates every upgrade button.
1023
+ * The waiver text is not overridable through `strings`: it is versioned.
1024
+ */
1025
+ withdrawalWaiver?: PayWithdrawalWaiver | null;
882
1026
  locale: string | null;
883
1027
  theme: ThemeConfig;
884
1028
  strings: Partial<PaywallStrings>;
885
1029
  container?: HTMLElement;
886
1030
  }
887
1031
  interface PaywallRendererCallbacks {
888
- onUpgrade: (sku: string) => void;
1032
+ /** `consent` is passed only when the paywall showed the withdrawal waiver (and it was ticked). */
1033
+ onUpgrade: (sku: string, consent?: UpgradeConsent) => void;
889
1034
  onClose: () => void;
890
1035
  onRestore?: () => void;
891
1036
  }
892
1037
  declare const PAYWALL_HOST_CLASS = "extenshi-paywall-host";
1038
+ declare const WITHDRAWAL_WAIVER_CLASS = "extenshi-withdrawal-waiver";
893
1039
  declare function escapeHtml(value: string): string;
894
1040
  declare function substitute(html: string, content: Record<string, string>): string;
895
1041
  declare function buildContent(view: PaywallView, strings: PaywallStrings): Record<string, string>;
@@ -905,18 +1051,23 @@ declare class PaywallRenderer {
905
1051
  show(view: PaywallView): HTMLElement;
906
1052
  hide(): void;
907
1053
  private prune;
1054
+ /**
1055
+ * Inserts the unticked waiver checkbox right before the first upgrade
1056
+ * button and keeps every upgrade button disabled until it is ticked.
1057
+ */
1058
+ private mountWaiver;
908
1059
  private bind;
909
1060
  private reveal;
910
1061
  private close;
911
1062
  }
912
1063
 
913
1064
  /**
914
- * Every string the SDK adds on top of the templates. English only for now;
915
- * iteration 12 T9 / 13 replaces this dictionary per locale. Do not add
916
- * promotional claims here without marketing/legal review (see
1065
+ * The paywall's strings in a locale, from the SDK dictionary (./i18n.ts).
1066
+ * Do not add promotional claims without marketing/legal review (see
917
1067
  * .claude/modules/paywall-templates.md).
918
1068
  */
919
1069
 
1070
+ /** English (the default and the fallback). */
920
1071
  declare const DEFAULT_STRINGS: PaywallStrings;
921
1072
 
922
1073
  /**
@@ -933,5 +1084,5 @@ declare const PAYWALL_SHARED_CSS: string;
933
1084
  declare const PAYWALL_TEMPLATES: Record<PaywallMode, PaywallTemplate>;
934
1085
  declare const PAYWALL_MODES: PaywallMode[];
935
1086
 
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 };
1087
+ 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 };
1088
+ 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 };