@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.
Files changed (88) hide show
  1. package/README.md +16 -10
  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 +219 -113
  13. package/dist/core.d.ts +219 -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 +1386 -191
  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 +1386 -191
  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 +1383 -192
  34. package/dist/extenshi-pay.mjs.map +1 -1
  35. package/dist/index.d.mts +287 -117
  36. package/dist/index.d.ts +287 -117
  37. package/dist/lite.d.mts +188 -83
  38. package/dist/lite.d.ts +188 -83
  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/icon.d.ts +18 -0
  50. package/dist/paywall/icon.d.ts.map +1 -0
  51. package/dist/paywall/index.d.ts +2 -1
  52. package/dist/paywall/index.d.ts.map +1 -1
  53. package/dist/paywall/license-panel.d.ts +4 -1
  54. package/dist/paywall/license-panel.d.ts.map +1 -1
  55. package/dist/paywall/renderer.d.ts +24 -2
  56. package/dist/paywall/renderer.d.ts.map +1 -1
  57. package/dist/paywall/seller-details.d.ts +2 -1
  58. package/dist/paywall/seller-details.d.ts.map +1 -1
  59. package/dist/paywall/strings.d.ts +6 -4
  60. package/dist/paywall/strings.d.ts.map +1 -1
  61. package/dist/paywall.d.mts +113 -8
  62. package/dist/paywall.d.ts +113 -8
  63. package/dist/paywall.js +1068 -51
  64. package/dist/paywall.js.map +1 -1
  65. package/dist/paywall.mjs +1066 -52
  66. package/dist/paywall.mjs.map +1 -1
  67. package/dist/types/config.d.ts +6 -1
  68. package/dist/types/config.d.ts.map +1 -1
  69. package/dist/types/contract.d.ts +25 -0
  70. package/dist/types/contract.d.ts.map +1 -1
  71. package/dist/types/entitlement.d.ts +22 -0
  72. package/dist/types/entitlement.d.ts.map +1 -1
  73. package/dist/types/errors.d.ts +1 -0
  74. package/dist/types/errors.d.ts.map +1 -1
  75. package/dist/types/paywall.d.ts +27 -3
  76. package/dist/types/paywall.d.ts.map +1 -1
  77. package/dist/version.d.ts +1 -1
  78. package/package.json +2 -2
  79. package/dist/core.esm.js +0 -1681
  80. package/dist/core.esm.js.map +0 -1
  81. package/dist/extenshi-pay-lite.esm.js +0 -1664
  82. package/dist/extenshi-pay-lite.esm.js.map +0 -1
  83. package/dist/extenshi-pay.esm.js +0 -2496
  84. package/dist/extenshi-pay.esm.js.map +0 -1
  85. package/dist/extenshi-pay.esm.min.js +0 -7
  86. package/dist/extenshi-pay.esm.min.js.map +0 -1
  87. package/dist/paywall.esm.js +0 -442
  88. package/dist/paywall.esm.js.map +0 -1
@@ -8,7 +8,8 @@
8
8
  * `addEventListener` on `data-ep-action` (no inline handlers, no scripts).
9
9
  */
10
10
  import type { ThemeConfig } from '../types/config.js';
11
- import type { PayOfferDto, PaySellerPublic } from '../types/contract.js';
11
+ import type { PayOfferDto, PaySellerPublic, PayWithdrawalWaiver } from '../types/contract.js';
12
+ import type { UpgradeConsent } from '../types/entitlement.js';
12
13
  import type { PaywallMode, PaywallStrings } from '../types/paywall.js';
13
14
  export interface PaywallView {
14
15
  mode: PaywallMode;
@@ -16,23 +17,33 @@ export interface PaywallView {
16
17
  description: string;
17
18
  features: string[];
18
19
  freeFeatures: string[];
20
+ /** Header image URL (./icon.ts) in place of the template's glyph; absent or null keeps the glyph. */
21
+ icon?: string | null;
19
22
  brandName: string;
20
23
  offer: PayOfferDto | null;
21
24
  checkoutEnabled: boolean;
22
25
  mock?: boolean;
23
26
  recoveryEnabled?: boolean;
24
27
  seller?: PaySellerPublic | null;
28
+ /**
29
+ * From `PayOfferResponse.withdrawalWaiver`: when set (and the offer is
30
+ * purchasable) an unticked waiver checkbox gates every upgrade button.
31
+ * The waiver text is not overridable through `strings`: it is versioned.
32
+ */
33
+ withdrawalWaiver?: PayWithdrawalWaiver | null;
25
34
  locale: string | null;
26
35
  theme: ThemeConfig;
27
36
  strings: Partial<PaywallStrings>;
28
37
  container?: HTMLElement;
29
38
  }
30
39
  export interface PaywallRendererCallbacks {
31
- onUpgrade: (sku: string) => void;
40
+ /** `consent` is passed only when the paywall showed the withdrawal waiver (and it was ticked). */
41
+ onUpgrade: (sku: string, consent?: UpgradeConsent) => void;
32
42
  onClose: () => void;
33
43
  onRestore?: () => void;
34
44
  }
35
45
  export declare const PAYWALL_HOST_CLASS = "extenshi-paywall-host";
46
+ export declare const WITHDRAWAL_WAIVER_CLASS = "extenshi-withdrawal-waiver";
36
47
  export declare function escapeHtml(value: string): string;
37
48
  export declare function substitute(html: string, content: Record<string, string>): string;
38
49
  export declare function buildContent(view: PaywallView, strings: PaywallStrings): Record<string, string>;
@@ -48,6 +59,17 @@ export declare class PaywallRenderer {
48
59
  show(view: PaywallView): HTMLElement;
49
60
  hide(): void;
50
61
  private prune;
62
+ /**
63
+ * Swaps the templates' product glyphs for the extension's icon. A tile's
64
+ * gradient only backs the white glyph, so it goes too; an image that fails
65
+ * to load puts the glyph (and the gradient) back.
66
+ */
67
+ private placeIcon;
68
+ /**
69
+ * Inserts the unticked waiver checkbox right before the first upgrade
70
+ * button and keeps every upgrade button disabled until it is ticked.
71
+ */
72
+ private mountWaiver;
51
73
  private bind;
52
74
  private reveal;
53
75
  private close;
@@ -1 +1 @@
1
- {"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../src/paywall/renderer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAExE,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAMtE,MAAM,WAAW,WAAW;IAC3B,IAAI,EAAE,WAAW,CAAA;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,YAAY,EAAE,MAAM,EAAE,CAAA;IACtB,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,WAAW,GAAG,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
  /** Treat even server-provided links as untrusted; never render executable protocols. */
3
4
  export declare function publicContactUrl(value: string): string | null;
4
- export declare function sellerDetails(seller: PaySellerPublic | null): HTMLElement;
5
+ export declare function sellerDetails(seller: PaySellerPublic | null, t?: SdkStrings): HTMLElement;
5
6
  //# sourceMappingURL=seller-details.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"seller-details.d.ts","sourceRoot":"","sources":["../../src/paywall/seller-details.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAE3D,wFAAwF;AACxF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAS7D;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI,GAAG,WAAW,CA4BzE"}
1
+ {"version":3,"file":"seller-details.d.ts","sourceRoot":"","sources":["../../src/paywall/seller-details.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,EAAwB,KAAK,UAAU,EAAE,MAAM,WAAW,CAAA;AAEjE,wFAAwF;AACxF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAS7D;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI,EAAE,CAAC,GAAE,UAA2B,GAAG,WAAW,CA0BzG"}
@@ -1,10 +1,12 @@
1
1
  /**
2
- * Every string the SDK adds on top of the templates. English only for now;
3
- * iteration 12 T9 / 13 replaces this dictionary per locale. Do not add
4
- * promotional claims here without marketing/legal review (see
2
+ * The paywall's strings in a locale, from the SDK dictionary (./i18n.ts).
3
+ * Do not add promotional claims without marketing/legal review (see
5
4
  * .claude/modules/paywall-templates.md).
6
5
  */
7
6
  import type { PaywallStrings } from '../types/paywall.js';
8
- export declare const MOCK_PAYMENT_NOTICE = "Development preview: licenses and payments are simulated. No payment will be taken.";
7
+ /** English (the default and the fallback). */
9
8
  export declare const DEFAULT_STRINGS: PaywallStrings;
9
+ export declare const MOCK_PAYMENT_NOTICE: string;
10
+ /** The paywall strings for `locale` (English when we have no translation). */
11
+ export declare function stringsFor(locale: string | null | undefined): PaywallStrings;
10
12
  //# sourceMappingURL=strings.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"strings.d.ts","sourceRoot":"","sources":["../../src/paywall/strings.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAEzD,eAAO,MAAM,mBAAmB,wFACsD,CAAA;AAEtF,eAAO,MAAM,eAAe,EAAE,cAc7B,CAAA"}
1
+ {"version":3,"file":"strings.d.ts","sourceRoot":"","sources":["../../src/paywall/strings.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AA2BzD,8CAA8C;AAC9C,eAAO,MAAM,eAAe,EAAE,cAA+C,CAAA;AAE7E,eAAO,MAAM,mBAAmB,QAA4B,CAAA;AAE5D,8EAA8E;AAC9E,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,cAAc,CAE5E"}
@@ -1,3 +1,46 @@
1
+ /**
2
+ * Every string the SDK shows to the USER of an extension — paywall, license
3
+ * dialog, billing-profile picker, seller details — in the end-user languages
4
+ * (ROADMAP it. 13 T10, stage L2; closes it. 12 T9). Developer-facing error
5
+ * messages stay English.
6
+ *
7
+ * Self-contained on purpose: the SDK ships inside third-party extensions with
8
+ * no runtime dependencies and no remote code, so the dictionary is compiled
9
+ * in. Placeholders are `{name}`, `{date}`, `{status}`. A missing
10
+ * translation falls back to English, never to an empty string. The same
11
+ * languages as the hosted pages (shared-types END_USER_LOCALES); keep the
12
+ * lists in sync.
13
+ */
14
+
15
+ declare const SDK_LOCALES: readonly ["en", "es", "pt-BR", "fr", "de", "it", "ru", "ja", "ko", "zh-CN", "ar"];
16
+ type SdkLocale = (typeof SDK_LOCALES)[number];
17
+
18
+ /**
19
+ * Buyer-facing withdrawal-waiver text (EU/EEA digital content, Directive
20
+ * 2011/83/EU art. 16(m); UK CCR 2013 reg. 37), per text version and SDK
21
+ * language. Its own module, not part of the paywall dictionary, so Lite can
22
+ * show it without bundling every paywall string.
23
+ *
24
+ * The recorded consent names the version, so a version's words never change:
25
+ * new wording is a new version here and a new PAY_WITHDRAWAL_WAIVER_VERSION.
26
+ *
27
+ * MIRRORED in shared-types/pay-withdrawal-waiver.ts, which the purchase
28
+ * confirmation email quotes; shared-types/pay-withdrawal-waiver.test.ts fails
29
+ * unless both copies are byte-identical. Change them together.
30
+ */
31
+
32
+ declare const WITHDRAWAL_WAIVER_TEXTS: Readonly<Record<string, Readonly<Record<SdkLocale, string>>>>;
33
+ /**
34
+ * The waiver text to show for `serverVersion`, and the version to send with
35
+ * the consent. A version this SDK does not know (a newer server) shows this
36
+ * SDK's current text and sends its version: the consent always names the words
37
+ * actually shown.
38
+ */
39
+ declare function withdrawalWaiverText(serverVersion: string, locale: string | null | undefined, seller: string): {
40
+ version: string;
41
+ text: string;
42
+ };
43
+
1
44
  declare const PAY_OFFER_KINDS: readonly ["one_time", "subscription", "lifetime"];
2
45
  type PayOfferKind = (typeof PAY_OFFER_KINDS)[number];
3
46
  declare const PAY_OFFER_INTERVALS: readonly ["month", "year"];
@@ -15,12 +58,17 @@ interface PayOfferDto {
15
58
  description: string | null;
16
59
  features: string[];
17
60
  }
61
+ interface PayWithdrawalWaiver {
62
+ version: string;
63
+ }
18
64
  /** Public author-provided contact details. Not a claim of identity verification. */
19
65
  interface PaySellerPublic {
20
66
  displayName: string;
21
67
  /** HTTPS support page or plain email address. */
22
68
  supportUrl: string;
23
69
  termsUrl: string | null;
70
+ /** Optional for older servers: refunds section of the license terms. */
71
+ refundPolicyUrl?: string | null;
24
72
  }
25
73
 
26
74
  interface ThemeConfig {
@@ -34,7 +82,11 @@ interface ThemeConfig {
34
82
  }
35
83
 
36
84
  type PaywallMode = 'modal' | 'inline' | 'sidebar' | 'fullscreen' | 'minimal';
37
- /** Every user-visible string the SDK adds on top of the templates (English only; iteration 12 T9 swaps locales). */
85
+ /**
86
+ * Every user-visible string the paywall adds on top of the templates. The SDK
87
+ * fills them in the configured `locale` (src/paywall/i18n.ts); pass `strings`
88
+ * to override any of them.
89
+ */
38
90
  interface PaywallStrings {
39
91
  title: string;
40
92
  description: string;
@@ -49,6 +101,13 @@ interface PaywallStrings {
49
101
  periodOnce: string;
50
102
  footer: string;
51
103
  restorePurchase: string;
104
+ /** Template headings and plan labels (were fixed English text in the templates). */
105
+ featuresHeading: string;
106
+ plansHeading: string;
107
+ freePlanName: string;
108
+ premiumPlanName: string;
109
+ popularBadge: string;
110
+ unlockHeading: string;
52
111
  }
53
112
  interface PaywallOptions {
54
113
  /** Template to render (default `modal`). */
@@ -57,18 +116,43 @@ interface PaywallOptions {
57
116
  sku?: string;
58
117
  title?: string;
59
118
  description?: string;
60
- /** Overrides the offer's `features[]`. */
119
+ /**
120
+ * Bullet points, in the user's language (`chrome.i18n.getMessage`). The
121
+ * offer's `features[]` are entitlement keys and are never shown: without
122
+ * this option the paywall has no feature list.
123
+ */
61
124
  features?: string[];
62
125
  /** Free-tier bullets for the comparison templates (`inline`, `fullscreen`). */
63
126
  freeFeatures?: string[];
127
+ /**
128
+ * Header image in place of the template's glyph: a path inside the
129
+ * extension (`icons/icon128.png`) or a `data:image/` URL. Defaults to the
130
+ * largest `manifest.icons` entry on the extension's own pages (popup,
131
+ * options); `false` keeps the glyph. Remote URLs are ignored.
132
+ */
133
+ icon?: string | false;
64
134
  theme?: ThemeConfig;
65
135
  /** Mount point for `inline` mode (default `document.body`). */
66
136
  container?: HTMLElement;
67
137
  strings?: Partial<PaywallStrings>;
68
- onUpgrade?: (sku: string) => void;
138
+ /** `consent` carries the withdrawal waiver when the paywall showed one. */
139
+ onUpgrade?: (sku: string, consent?: UpgradeConsent) => void;
69
140
  onClose?: () => void;
70
141
  }
71
142
 
143
+ /**
144
+ * The buyer ticked the withdrawal-waiver checkbox (EU/EEA/UK digital content).
145
+ * `version` names the waiver words that were shown (`PAY_WITHDRAWAL_WAIVER_VERSION`).
146
+ */
147
+ interface WithdrawalWaiverConsent {
148
+ version: string;
149
+ accepted: true;
150
+ }
151
+ /** What a paywall upgrade click carries besides the SKU. */
152
+ interface UpgradeConsent {
153
+ withdrawalWaiver?: WithdrawalWaiverConsent;
154
+ }
155
+
72
156
  interface FormattedPrice {
73
157
  /** Currency symbol/code as the locale renders it (`$`, `€`, `US$`). */
74
158
  currency: string;
@@ -96,23 +180,33 @@ interface PaywallView {
96
180
  description: string;
97
181
  features: string[];
98
182
  freeFeatures: string[];
183
+ /** Header image URL (./icon.ts) in place of the template's glyph; absent or null keeps the glyph. */
184
+ icon?: string | null;
99
185
  brandName: string;
100
186
  offer: PayOfferDto | null;
101
187
  checkoutEnabled: boolean;
102
188
  mock?: boolean;
103
189
  recoveryEnabled?: boolean;
104
190
  seller?: PaySellerPublic | null;
191
+ /**
192
+ * From `PayOfferResponse.withdrawalWaiver`: when set (and the offer is
193
+ * purchasable) an unticked waiver checkbox gates every upgrade button.
194
+ * The waiver text is not overridable through `strings`: it is versioned.
195
+ */
196
+ withdrawalWaiver?: PayWithdrawalWaiver | null;
105
197
  locale: string | null;
106
198
  theme: ThemeConfig;
107
199
  strings: Partial<PaywallStrings>;
108
200
  container?: HTMLElement;
109
201
  }
110
202
  interface PaywallRendererCallbacks {
111
- onUpgrade: (sku: string) => void;
203
+ /** `consent` is passed only when the paywall showed the withdrawal waiver (and it was ticked). */
204
+ onUpgrade: (sku: string, consent?: UpgradeConsent) => void;
112
205
  onClose: () => void;
113
206
  onRestore?: () => void;
114
207
  }
115
208
  declare const PAYWALL_HOST_CLASS = "extenshi-paywall-host";
209
+ declare const WITHDRAWAL_WAIVER_CLASS = "extenshi-withdrawal-waiver";
116
210
  declare function escapeHtml(value: string): string;
117
211
  declare function substitute(html: string, content: Record<string, string>): string;
118
212
  declare function buildContent(view: PaywallView, strings: PaywallStrings): Record<string, string>;
@@ -128,18 +222,29 @@ declare class PaywallRenderer {
128
222
  show(view: PaywallView): HTMLElement;
129
223
  hide(): void;
130
224
  private prune;
225
+ /**
226
+ * Swaps the templates' product glyphs for the extension's icon. A tile's
227
+ * gradient only backs the white glyph, so it goes too; an image that fails
228
+ * to load puts the glyph (and the gradient) back.
229
+ */
230
+ private placeIcon;
231
+ /**
232
+ * Inserts the unticked waiver checkbox right before the first upgrade
233
+ * button and keeps every upgrade button disabled until it is ticked.
234
+ */
235
+ private mountWaiver;
131
236
  private bind;
132
237
  private reveal;
133
238
  private close;
134
239
  }
135
240
 
136
241
  /**
137
- * Every string the SDK adds on top of the templates. English only for now;
138
- * iteration 12 T9 / 13 replaces this dictionary per locale. Do not add
139
- * promotional claims here without marketing/legal review (see
242
+ * The paywall's strings in a locale, from the SDK dictionary (./i18n.ts).
243
+ * Do not add promotional claims without marketing/legal review (see
140
244
  * .claude/modules/paywall-templates.md).
141
245
  */
142
246
 
247
+ /** English (the default and the fallback). */
143
248
  declare const DEFAULT_STRINGS: PaywallStrings;
144
249
 
145
250
  /**
@@ -156,5 +261,5 @@ declare const PAYWALL_SHARED_CSS: string;
156
261
  declare const PAYWALL_TEMPLATES: Record<PaywallMode, PaywallTemplate>;
157
262
  declare const PAYWALL_MODES: PaywallMode[];
158
263
 
159
- export { DEFAULT_STRINGS, PAYWALL_HOST_CLASS, PAYWALL_MODES, PAYWALL_SHARED_CSS, PAYWALL_TEMPLATES, PaywallRenderer, buildContent, escapeHtml, formatPrice, periodLabel, resolveThemeMode, substitute, themeCss };
264
+ export { DEFAULT_STRINGS, PAYWALL_HOST_CLASS, PAYWALL_MODES, PAYWALL_SHARED_CSS, PAYWALL_TEMPLATES, PaywallRenderer, WITHDRAWAL_WAIVER_CLASS, WITHDRAWAL_WAIVER_TEXTS, buildContent, escapeHtml, formatPrice, periodLabel, resolveThemeMode, substitute, themeCss, withdrawalWaiverText };
160
265
  export type { FormattedPrice, PaywallMode, PaywallOptions, PaywallRendererCallbacks, PaywallStrings, PaywallTemplate, PaywallView, ThemeConfig };
package/dist/paywall.d.ts CHANGED
@@ -1,3 +1,46 @@
1
+ /**
2
+ * Every string the SDK shows to the USER of an extension — paywall, license
3
+ * dialog, billing-profile picker, seller details — in the end-user languages
4
+ * (ROADMAP it. 13 T10, stage L2; closes it. 12 T9). Developer-facing error
5
+ * messages stay English.
6
+ *
7
+ * Self-contained on purpose: the SDK ships inside third-party extensions with
8
+ * no runtime dependencies and no remote code, so the dictionary is compiled
9
+ * in. Placeholders are `{name}`, `{date}`, `{status}`. A missing
10
+ * translation falls back to English, never to an empty string. The same
11
+ * languages as the hosted pages (shared-types END_USER_LOCALES); keep the
12
+ * lists in sync.
13
+ */
14
+
15
+ declare const SDK_LOCALES: readonly ["en", "es", "pt-BR", "fr", "de", "it", "ru", "ja", "ko", "zh-CN", "ar"];
16
+ type SdkLocale = (typeof SDK_LOCALES)[number];
17
+
18
+ /**
19
+ * Buyer-facing withdrawal-waiver text (EU/EEA digital content, Directive
20
+ * 2011/83/EU art. 16(m); UK CCR 2013 reg. 37), per text version and SDK
21
+ * language. Its own module, not part of the paywall dictionary, so Lite can
22
+ * show it without bundling every paywall string.
23
+ *
24
+ * The recorded consent names the version, so a version's words never change:
25
+ * new wording is a new version here and a new PAY_WITHDRAWAL_WAIVER_VERSION.
26
+ *
27
+ * MIRRORED in shared-types/pay-withdrawal-waiver.ts, which the purchase
28
+ * confirmation email quotes; shared-types/pay-withdrawal-waiver.test.ts fails
29
+ * unless both copies are byte-identical. Change them together.
30
+ */
31
+
32
+ declare const WITHDRAWAL_WAIVER_TEXTS: Readonly<Record<string, Readonly<Record<SdkLocale, string>>>>;
33
+ /**
34
+ * The waiver text to show for `serverVersion`, and the version to send with
35
+ * the consent. A version this SDK does not know (a newer server) shows this
36
+ * SDK's current text and sends its version: the consent always names the words
37
+ * actually shown.
38
+ */
39
+ declare function withdrawalWaiverText(serverVersion: string, locale: string | null | undefined, seller: string): {
40
+ version: string;
41
+ text: string;
42
+ };
43
+
1
44
  declare const PAY_OFFER_KINDS: readonly ["one_time", "subscription", "lifetime"];
2
45
  type PayOfferKind = (typeof PAY_OFFER_KINDS)[number];
3
46
  declare const PAY_OFFER_INTERVALS: readonly ["month", "year"];
@@ -15,12 +58,17 @@ interface PayOfferDto {
15
58
  description: string | null;
16
59
  features: string[];
17
60
  }
61
+ interface PayWithdrawalWaiver {
62
+ version: string;
63
+ }
18
64
  /** Public author-provided contact details. Not a claim of identity verification. */
19
65
  interface PaySellerPublic {
20
66
  displayName: string;
21
67
  /** HTTPS support page or plain email address. */
22
68
  supportUrl: string;
23
69
  termsUrl: string | null;
70
+ /** Optional for older servers: refunds section of the license terms. */
71
+ refundPolicyUrl?: string | null;
24
72
  }
25
73
 
26
74
  interface ThemeConfig {
@@ -34,7 +82,11 @@ interface ThemeConfig {
34
82
  }
35
83
 
36
84
  type PaywallMode = 'modal' | 'inline' | 'sidebar' | 'fullscreen' | 'minimal';
37
- /** Every user-visible string the SDK adds on top of the templates (English only; iteration 12 T9 swaps locales). */
85
+ /**
86
+ * Every user-visible string the paywall adds on top of the templates. The SDK
87
+ * fills them in the configured `locale` (src/paywall/i18n.ts); pass `strings`
88
+ * to override any of them.
89
+ */
38
90
  interface PaywallStrings {
39
91
  title: string;
40
92
  description: string;
@@ -49,6 +101,13 @@ interface PaywallStrings {
49
101
  periodOnce: string;
50
102
  footer: string;
51
103
  restorePurchase: string;
104
+ /** Template headings and plan labels (were fixed English text in the templates). */
105
+ featuresHeading: string;
106
+ plansHeading: string;
107
+ freePlanName: string;
108
+ premiumPlanName: string;
109
+ popularBadge: string;
110
+ unlockHeading: string;
52
111
  }
53
112
  interface PaywallOptions {
54
113
  /** Template to render (default `modal`). */
@@ -57,18 +116,43 @@ interface PaywallOptions {
57
116
  sku?: string;
58
117
  title?: string;
59
118
  description?: string;
60
- /** Overrides the offer's `features[]`. */
119
+ /**
120
+ * Bullet points, in the user's language (`chrome.i18n.getMessage`). The
121
+ * offer's `features[]` are entitlement keys and are never shown: without
122
+ * this option the paywall has no feature list.
123
+ */
61
124
  features?: string[];
62
125
  /** Free-tier bullets for the comparison templates (`inline`, `fullscreen`). */
63
126
  freeFeatures?: string[];
127
+ /**
128
+ * Header image in place of the template's glyph: a path inside the
129
+ * extension (`icons/icon128.png`) or a `data:image/` URL. Defaults to the
130
+ * largest `manifest.icons` entry on the extension's own pages (popup,
131
+ * options); `false` keeps the glyph. Remote URLs are ignored.
132
+ */
133
+ icon?: string | false;
64
134
  theme?: ThemeConfig;
65
135
  /** Mount point for `inline` mode (default `document.body`). */
66
136
  container?: HTMLElement;
67
137
  strings?: Partial<PaywallStrings>;
68
- onUpgrade?: (sku: string) => void;
138
+ /** `consent` carries the withdrawal waiver when the paywall showed one. */
139
+ onUpgrade?: (sku: string, consent?: UpgradeConsent) => void;
69
140
  onClose?: () => void;
70
141
  }
71
142
 
143
+ /**
144
+ * The buyer ticked the withdrawal-waiver checkbox (EU/EEA/UK digital content).
145
+ * `version` names the waiver words that were shown (`PAY_WITHDRAWAL_WAIVER_VERSION`).
146
+ */
147
+ interface WithdrawalWaiverConsent {
148
+ version: string;
149
+ accepted: true;
150
+ }
151
+ /** What a paywall upgrade click carries besides the SKU. */
152
+ interface UpgradeConsent {
153
+ withdrawalWaiver?: WithdrawalWaiverConsent;
154
+ }
155
+
72
156
  interface FormattedPrice {
73
157
  /** Currency symbol/code as the locale renders it (`$`, `€`, `US$`). */
74
158
  currency: string;
@@ -96,23 +180,33 @@ interface PaywallView {
96
180
  description: string;
97
181
  features: string[];
98
182
  freeFeatures: string[];
183
+ /** Header image URL (./icon.ts) in place of the template's glyph; absent or null keeps the glyph. */
184
+ icon?: string | null;
99
185
  brandName: string;
100
186
  offer: PayOfferDto | null;
101
187
  checkoutEnabled: boolean;
102
188
  mock?: boolean;
103
189
  recoveryEnabled?: boolean;
104
190
  seller?: PaySellerPublic | null;
191
+ /**
192
+ * From `PayOfferResponse.withdrawalWaiver`: when set (and the offer is
193
+ * purchasable) an unticked waiver checkbox gates every upgrade button.
194
+ * The waiver text is not overridable through `strings`: it is versioned.
195
+ */
196
+ withdrawalWaiver?: PayWithdrawalWaiver | null;
105
197
  locale: string | null;
106
198
  theme: ThemeConfig;
107
199
  strings: Partial<PaywallStrings>;
108
200
  container?: HTMLElement;
109
201
  }
110
202
  interface PaywallRendererCallbacks {
111
- onUpgrade: (sku: string) => void;
203
+ /** `consent` is passed only when the paywall showed the withdrawal waiver (and it was ticked). */
204
+ onUpgrade: (sku: string, consent?: UpgradeConsent) => void;
112
205
  onClose: () => void;
113
206
  onRestore?: () => void;
114
207
  }
115
208
  declare const PAYWALL_HOST_CLASS = "extenshi-paywall-host";
209
+ declare const WITHDRAWAL_WAIVER_CLASS = "extenshi-withdrawal-waiver";
116
210
  declare function escapeHtml(value: string): string;
117
211
  declare function substitute(html: string, content: Record<string, string>): string;
118
212
  declare function buildContent(view: PaywallView, strings: PaywallStrings): Record<string, string>;
@@ -128,18 +222,29 @@ declare class PaywallRenderer {
128
222
  show(view: PaywallView): HTMLElement;
129
223
  hide(): void;
130
224
  private prune;
225
+ /**
226
+ * Swaps the templates' product glyphs for the extension's icon. A tile's
227
+ * gradient only backs the white glyph, so it goes too; an image that fails
228
+ * to load puts the glyph (and the gradient) back.
229
+ */
230
+ private placeIcon;
231
+ /**
232
+ * Inserts the unticked waiver checkbox right before the first upgrade
233
+ * button and keeps every upgrade button disabled until it is ticked.
234
+ */
235
+ private mountWaiver;
131
236
  private bind;
132
237
  private reveal;
133
238
  private close;
134
239
  }
135
240
 
136
241
  /**
137
- * Every string the SDK adds on top of the templates. English only for now;
138
- * iteration 12 T9 / 13 replaces this dictionary per locale. Do not add
139
- * promotional claims here without marketing/legal review (see
242
+ * The paywall's strings in a locale, from the SDK dictionary (./i18n.ts).
243
+ * Do not add promotional claims without marketing/legal review (see
140
244
  * .claude/modules/paywall-templates.md).
141
245
  */
142
246
 
247
+ /** English (the default and the fallback). */
143
248
  declare const DEFAULT_STRINGS: PaywallStrings;
144
249
 
145
250
  /**
@@ -156,5 +261,5 @@ declare const PAYWALL_SHARED_CSS: string;
156
261
  declare const PAYWALL_TEMPLATES: Record<PaywallMode, PaywallTemplate>;
157
262
  declare const PAYWALL_MODES: PaywallMode[];
158
263
 
159
- export { DEFAULT_STRINGS, PAYWALL_HOST_CLASS, PAYWALL_MODES, PAYWALL_SHARED_CSS, PAYWALL_TEMPLATES, PaywallRenderer, buildContent, escapeHtml, formatPrice, periodLabel, resolveThemeMode, substitute, themeCss };
264
+ export { DEFAULT_STRINGS, PAYWALL_HOST_CLASS, PAYWALL_MODES, PAYWALL_SHARED_CSS, PAYWALL_TEMPLATES, PaywallRenderer, WITHDRAWAL_WAIVER_CLASS, WITHDRAWAL_WAIVER_TEXTS, buildContent, escapeHtml, formatPrice, periodLabel, resolveThemeMode, substitute, themeCss, withdrawalWaiverText };
160
265
  export type { FormattedPrice, PaywallMode, PaywallOptions, PaywallRendererCallbacks, PaywallStrings, PaywallTemplate, PaywallView, ThemeConfig };