@extenshi/pay 0.9.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/README.md +138 -17
  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 +9 -4
  5. package/dist/api/pay-api.d.ts.map +1 -1
  6. package/dist/core/config.d.ts.map +1 -1
  7. package/dist/core/extenshi-pay.d.ts +60 -5
  8. package/dist/core/extenshi-pay.d.ts.map +1 -1
  9. package/dist/core/index.d.ts +3 -1
  10. package/dist/core/index.d.ts.map +1 -1
  11. package/dist/core/storage.d.ts +6 -0
  12. package/dist/core/storage.d.ts.map +1 -1
  13. package/dist/core.d.mts +271 -26
  14. package/dist/core.d.ts +271 -26
  15. package/dist/core.js +589 -49
  16. package/dist/core.js.map +1 -1
  17. package/dist/core.mjs +584 -50
  18. package/dist/core.mjs.map +1 -1
  19. package/dist/extenshi-pay-lite.js +577 -49
  20. package/dist/extenshi-pay-lite.js.map +1 -1
  21. package/dist/extenshi-pay-lite.min.js +3 -3
  22. package/dist/extenshi-pay-lite.min.js.map +1 -1
  23. package/dist/extenshi-pay-lite.mjs +577 -49
  24. package/dist/extenshi-pay-lite.mjs.map +1 -1
  25. package/dist/extenshi-pay.cjs.js +694 -61
  26. package/dist/extenshi-pay.cjs.js.map +1 -1
  27. package/dist/extenshi-pay.d.ts +11 -1
  28. package/dist/extenshi-pay.d.ts.map +1 -1
  29. package/dist/extenshi-pay.js +694 -61
  30. package/dist/extenshi-pay.js.map +1 -1
  31. package/dist/extenshi-pay.min.js +3 -3
  32. package/dist/extenshi-pay.min.js.map +1 -1
  33. package/dist/extenshi-pay.min.mjs +3 -3
  34. package/dist/extenshi-pay.min.mjs.map +1 -1
  35. package/dist/extenshi-pay.mjs +689 -62
  36. package/dist/extenshi-pay.mjs.map +1 -1
  37. package/dist/index.d.mts +288 -26
  38. package/dist/index.d.ts +288 -26
  39. package/dist/lite.d.mts +214 -13
  40. package/dist/lite.d.ts +214 -13
  41. package/dist/lite.d.ts.map +1 -1
  42. package/dist/payment/cloud-backup.d.ts +35 -0
  43. package/dist/payment/cloud-backup.d.ts.map +1 -0
  44. package/dist/payment/entitlement.d.ts +21 -5
  45. package/dist/payment/entitlement.d.ts.map +1 -1
  46. package/dist/payment/recovery.d.ts +4 -2
  47. package/dist/payment/recovery.d.ts.map +1 -1
  48. package/dist/payment/signature.d.ts +29 -3
  49. package/dist/payment/signature.d.ts.map +1 -1
  50. package/dist/payment/trial.d.ts +55 -0
  51. package/dist/payment/trial.d.ts.map +1 -0
  52. package/dist/paywall/i18n.d.ts +3 -0
  53. package/dist/paywall/i18n.d.ts.map +1 -1
  54. package/dist/paywall/renderer.d.ts +7 -0
  55. package/dist/paywall/renderer.d.ts.map +1 -1
  56. package/dist/paywall.d.mts +7 -0
  57. package/dist/paywall.d.ts +7 -0
  58. package/dist/paywall.js +54 -14
  59. package/dist/paywall.js.map +1 -1
  60. package/dist/paywall.mjs +54 -14
  61. package/dist/paywall.mjs.map +1 -1
  62. package/dist/types/config.d.ts +27 -1
  63. package/dist/types/config.d.ts.map +1 -1
  64. package/dist/types/contract.d.ts +36 -0
  65. package/dist/types/contract.d.ts.map +1 -1
  66. package/dist/types/entitlement.d.ts +39 -1
  67. package/dist/types/entitlement.d.ts.map +1 -1
  68. package/dist/types/events.d.ts +5 -1
  69. package/dist/types/events.d.ts.map +1 -1
  70. package/dist/types/paywall.d.ts +10 -0
  71. package/dist/types/paywall.d.ts.map +1 -1
  72. package/dist/version.d.ts +1 -1
  73. package/dist/version.d.ts.map +1 -1
  74. package/package.json +3 -2
package/dist/lite.d.mts CHANGED
@@ -90,6 +90,16 @@ interface PayEntitlementItem {
90
90
  expiresAt: string | null;
91
91
  features: string[];
92
92
  }
93
+ /**
94
+ * The installation's free trial on the server clock: one per installation per application,
95
+ * started at its first license read. Absent when the application has no trial.
96
+ */
97
+ interface PayTrial {
98
+ /** ISO time of the first license read while the application had a trial. */
99
+ startedAt: string;
100
+ /** ISO `startedAt` plus the application's current trial length. */
101
+ endsAt: string;
102
+ }
93
103
  interface PayEntitlementPayload {
94
104
  v: typeof PAY_CONTRACT_VERSION;
95
105
  /** Signed application scope; prevents moving a grant to another application. */
@@ -98,6 +108,10 @@ interface PayEntitlementPayload {
98
108
  entitlements: PayEntitlementItem[];
99
109
  /** ISO timestamp the projection was computed at; the SDK uses it for cache age. */
100
110
  issuedAt: string;
111
+ /** Optional: only for an application with a trial, and absent from older servers. */
112
+ trial?: PayTrial;
113
+ /** Optional: seconds of offline access after `issuedAt`; absent from older servers (48 hours). */
114
+ offlineSeconds?: number;
101
115
  }
102
116
  interface SignedEntitlement {
103
117
  payload: PayEntitlementPayload;
@@ -126,12 +140,31 @@ interface PayRestoreSessionResponse {
126
140
  expiresAt: string;
127
141
  url: string;
128
142
  }
143
+ /**
144
+ * `storage`: the buyer turns on the cloud copy of the extension's settings. The
145
+ * hosted page shows the storage disclosure; the claim records consent. Additive:
146
+ * a session without a purpose is a plain restore.
147
+ */
148
+ declare const PAY_RESTORE_PURPOSES: readonly ["restore", "storage"];
149
+ type PayRestorePurpose = (typeof PAY_RESTORE_PURPOSES)[number];
150
+ /**
151
+ * Outcome for the cloud copy of settings, present in a complete claim only when
152
+ * the application offers it. A token is returned once; a retried claim rotates it.
153
+ */
154
+ type PayStorageGrant = {
155
+ state: 'granted';
156
+ token: string;
157
+ } | {
158
+ state: 'unavailable';
159
+ reason: 'NO_CONSENT' | 'LICENSE_REQUIRED';
160
+ };
129
161
  type PayRestoreClaimResponse = {
130
162
  state: 'pending';
131
163
  } | {
132
164
  state: 'complete';
133
165
  endUserRef: string;
134
166
  entitlement: SignedEntitlement;
167
+ storage?: PayStorageGrant;
135
168
  };
136
169
  /** A project-scoped billing profile; provider identifiers are never exposed. */
137
170
  interface PayPortalAccount {
@@ -218,6 +251,20 @@ interface MockData {
218
251
  * paywall previews the checkbox). `null` previews a seller outside the EEA/UK.
219
252
  */
220
253
  withdrawalWaiver?: PayWithdrawalWaiver | null;
254
+ /**
255
+ * Seller details for the paywall, the license panel and the waiver text.
256
+ * Omitted, the offer carries none (as from an older server); `null`
257
+ * previews a seller without public details, so the paywall disables purchase.
258
+ */
259
+ seller?: PaySellerPublic | null;
260
+ /**
261
+ * Previews a server trial: `days` long, started at `startedAt` (default: when the mock is
262
+ * created). Omitted, the mock application has no trial.
263
+ */
264
+ trial?: {
265
+ days: number;
266
+ startedAt?: string;
267
+ };
221
268
  }
222
269
  interface ExtenshiPayConfig {
223
270
  /** `pk_ext_` + 32 hex characters, from the project's Monetization tab. */
@@ -239,6 +286,15 @@ interface ExtenshiPayConfig {
239
286
  onReady?: () => void;
240
287
  onError?: (error: ExtenshiPayError) => void;
241
288
  theme?: ThemeConfig;
289
+ /** Days before the trial's end that `trial:ending` fires (default 2; 0 turns it off). */
290
+ trialEndingDays?: number;
291
+ /**
292
+ * Keep the trial's start date in `storage.sync` and send it back on license checks, so
293
+ * other devices on the same synced browser account share the trial (default true).
294
+ * Only the date is synced, never the installation id. A reinstall still restarts the
295
+ * trial: uninstalling clears `storage.sync`.
296
+ */
297
+ syncTrialStart?: boolean;
242
298
  }
243
299
  interface ResolvedConfig {
244
300
  publishableKey: string;
@@ -252,6 +308,8 @@ interface ResolvedConfig {
252
308
  mock: boolean;
253
309
  mockData: MockData | null;
254
310
  theme: ThemeConfig;
311
+ trialEndingDays: number;
312
+ syncTrialStart: boolean;
255
313
  }
256
314
 
257
315
  type PaywallMode = 'modal' | 'inline' | 'sidebar' | 'fullscreen' | 'minimal';
@@ -319,6 +377,8 @@ interface Entitlement {
319
377
  items: PayEntitlementItem[];
320
378
  /** Union of `features[]` over active/grace items. */
321
379
  features: string[];
380
+ /** Signed expiry of regional free access, independent of any purchase. */
381
+ regionalFreeUntil?: number;
322
382
  /** True only when the Ed25519 signature was checked against the project's key. */
323
383
  verified: boolean;
324
384
  issuedAt: string | null;
@@ -328,8 +388,33 @@ interface Entitlement {
328
388
  requiresOnlineCheck?: boolean;
329
389
  /** Local offline-access deadline; null for mock mode or no cached license. */
330
390
  offlineUntil?: number | null;
391
+ /**
392
+ * Set when the device clock differed from the server's by more than 5 minutes at the last
393
+ * license check. With `requiresOnlineCheck` on a connected device, ask the user to correct
394
+ * the date and time instead of asking them to connect.
395
+ */
396
+ clockSkew?: ClockSkew | null;
331
397
  source: EntitlementSource;
332
398
  }
399
+ interface ClockSkew {
400
+ /** `ahead`: the device clock is later than the server's. */
401
+ direction: 'ahead' | 'behind';
402
+ /** Size of the difference in milliseconds. */
403
+ ms: number;
404
+ }
405
+ /** `getTrial()`: the free trial from the verified license, on the server's clock. */
406
+ interface TrialState {
407
+ /** True while the trial runs and the license was checked within the last 48 hours, as for paid access. */
408
+ active: boolean;
409
+ /** ISO time of the installation's first license check while the application had a trial. */
410
+ startedAt: string;
411
+ /** ISO time the trial ends. */
412
+ endsAt: string;
413
+ /** Whole days left, rounded up; 0 once the trial has ended. */
414
+ daysLeft: number;
415
+ /** The trial has days left but the license was not checked within 48 hours: connect to resume it. */
416
+ requiresOnlineCheck: boolean;
417
+ }
333
418
  interface GetEntitlementOptions {
334
419
  /** Skip the cache TTL and hit the network. */
335
420
  force?: boolean;
@@ -385,10 +470,21 @@ interface RestoreOptions {
385
470
  pollIntervalMs?: number;
386
471
  signal?: AbortSignal;
387
472
  openUrl?: (url: string) => void | Promise<void>;
473
+ /**
474
+ * `storage` also turns on the cloud copy of settings: the hosted page shows
475
+ * the storage disclosure first. `enableCloudBackup()` passes it. Default: a plain restore.
476
+ */
477
+ purpose?: PayRestorePurpose;
388
478
  }
479
+ /**
480
+ * The cloud copy of settings after a completed restore: `on` (the token is
481
+ * stored), or why it is off. Absent when the application does not offer it.
482
+ */
483
+ type CloudBackupState = 'on' | 'no_consent' | 'license_required';
389
484
  type RestoreResult = {
390
485
  state: 'complete';
391
486
  entitlement: Entitlement;
487
+ cloudBackup?: CloudBackupState;
392
488
  } | {
393
489
  state: 'timeout' | 'expired' | 'canceled';
394
490
  };
@@ -440,11 +536,15 @@ declare class MockTransport implements Transport {
440
536
  private readonly checkoutEnabled;
441
537
  private readonly claimAfterPolls;
442
538
  private readonly withdrawalWaiver;
539
+ private readonly seller;
540
+ private trial;
443
541
  readonly sessions: Map<string, MockSession>;
444
542
  constructor(data?: MockData);
445
543
  call<T>(procedure: string, _kind: ProcedureKind, input: Record<string, unknown>): Promise<T>;
446
544
  /** Test/dev helpers. */
447
545
  setEntitlements(items: PayEntitlementItem[]): void;
546
+ /** Previews a server trial of `days` from `startedAt` (default now); `null` removes it. */
547
+ setTrial(days: number | null, startedAt?: string): void;
448
548
  cancelSession(sessionId: string): void;
449
549
  expireSession(sessionId: string): void;
450
550
  private offerResponse;
@@ -460,8 +560,12 @@ declare class PayApi {
460
560
  private readonly transport;
461
561
  private readonly publishableKey;
462
562
  constructor(transport: Transport, publishableKey: string);
463
- /** `locale` opens the hosted recovery page (and its email) in the user's language. */
464
- createRestoreSession(claimChallenge: string, locale?: string | null): Promise<PayRestoreSessionResponse>;
563
+ /**
564
+ * `locale` opens the hosted recovery page (and its email) in the user's language.
565
+ * `purpose` is sent only for `storage`: a plain restore keeps the request older
566
+ * BFFs know, and their non-strict zod input strips the key anyway.
567
+ */
568
+ createRestoreSession(claimChallenge: string, locale?: string | null, purpose?: PayRestorePurpose): Promise<PayRestoreSessionResponse>;
465
569
  claimRestoreSession(sessionId: string, claimSecret: string): Promise<PayRestoreClaimResponse>;
466
570
  getOffer(locale?: string | null): Promise<PayOfferResponse>;
467
571
  /**
@@ -471,7 +575,8 @@ declare class PayApi {
471
575
  */
472
576
  createCheckout(sku: string, endUserRef: string, locale?: string | null, withdrawalWaiver?: WithdrawalWaiverConsent): Promise<PayCheckoutSession>;
473
577
  claimSession(sessionId: string, endUserRef: string): Promise<PayCheckoutClaim>;
474
- getEntitlement(endUserRef: string): Promise<SignedEntitlement>;
578
+ /** `trialStartedHint`: the trial start kept in storage.sync; the server only lets it move a start earlier. */
579
+ getEntitlement(endUserRef: string, trialStartedHint?: string | null): Promise<SignedEntitlement>;
475
580
  getPortalUrl(endUserRef: string, customerId?: string, locale?: string | null): Promise<PayPortalResponse>;
476
581
  }
477
582
 
@@ -512,6 +617,10 @@ interface ExtenshiPayEvents {
512
617
  sku: string;
513
618
  sessionId: string;
514
619
  };
620
+ /** Once per installation and trial, `trialEndingDays` before the end, while the user has no paid access. */
621
+ 'trial:ending': TrialState;
622
+ /** Once per installation and trial, when it has ended, while the user has no paid access. */
623
+ 'trial:ended': TrialState;
515
624
  error: ExtenshiPayError;
516
625
  }
517
626
  type ExtenshiPayEventName = keyof ExtenshiPayEvents;
@@ -555,13 +664,36 @@ declare class CheckoutManager {
555
664
  private settle;
556
665
  }
557
666
 
667
+ /**
668
+ * Ed25519 verification of the entitlement projection.
669
+ *
670
+ * Tamper resistance, not DRM. Callers must deny access for both invalid and
671
+ * unverified envelopes outside explicit mocks.
672
+ *
673
+ * Which keys are trusted, in order (`PublicKeySource`, built in core/extenshi-pay.ts):
674
+ * 1. the key the server returned over HTTPS in this session;
675
+ * 2. the bundled `entitlementPublicKey`, when the developer configured one. It pins
676
+ * verification without a round-trip: a key read from extension storage is then never used;
677
+ * 3. without a bundled key, the server key saved in `storage.local` next to the
678
+ * license cache, so a restart with no network can still verify the cache.
679
+ * When none of them verifies an envelope the server is asked for its current key once
680
+ * (a rotated key), and that answer decides.
681
+ */
682
+
683
+ interface PublicKeySource {
684
+ /** Keys trusted without a round-trip, in the order above. */
685
+ known(): Promise<string[]>;
686
+ /** The server's current key, fetched now; null when the server signs nothing. Rejects when unreachable. */
687
+ fetchCurrent(): Promise<string | null>;
688
+ }
689
+
558
690
  /**
559
691
  * Entitlement cache + refresh.
560
692
  *
561
693
  * The cached envelope is a cache OF the server projection, never a second
562
694
  * source of truth: it is verified when stored and re-verified on load (once
563
695
  * the project's public key is known), served without a round-trip while the
564
- * TTL holds, served for up to 48 hours after signed issuance when the network is down, and expired
696
+ * TTL holds, served after signed issuance for the signed `offlineSeconds` (48 hours when absent) when the network is down, and expired
565
697
  * locally by `expiresAt`. Background refresh polls at most every 15 minutes
566
698
  * and backs off exponentially on errors.
567
699
  */
@@ -573,9 +705,13 @@ interface EntitlementManagerOptions {
573
705
  cacheTtlMs: number;
574
706
  source?: EntitlementSource;
575
707
  getEndUserRef: () => Promise<string>;
576
- /** Base64 raw Ed25519 public key from `getOffer`, or null when unknown/unsigned. */
577
- getPublicKey: () => Promise<string | null>;
708
+ /** The trusted Ed25519 keys, in order, and how to ask the server for its current one. */
709
+ keys: PublicKeySource;
578
710
  onChange?: (entitlement: Entitlement) => void;
711
+ /** After every accepted envelope, changed or not (the trial is not part of `onChange`). */
712
+ onAccepted?: () => void;
713
+ /** The synced trial start to send with a refresh; null when there is none. */
714
+ getTrialStartHint?: () => Promise<string | null>;
579
715
  onError?: (error: ExtenshiPayError) => void;
580
716
  now?: () => number;
581
717
  }
@@ -583,6 +719,8 @@ declare class EntitlementManager {
583
719
  private readonly options;
584
720
  private held;
585
721
  private inflight;
722
+ /** Device clock against the server's at the last license check; null within 5 minutes. */
723
+ private clockSkew;
586
724
  private timer;
587
725
  private refreshGeneration;
588
726
  private deadlineTimer;
@@ -599,7 +737,11 @@ declare class EntitlementManager {
599
737
  load(): Promise<Entitlement | null>;
600
738
  /** Re-checks the loaded envelope against the project's key; discards it when the signature is invalid. */
601
739
  reverify(): Promise<void>;
740
+ /** The key the held license was verified with; null when there is none or it is unverified. */
741
+ get verifiedKey(): string | null;
602
742
  getCached(): Entitlement | null;
743
+ /** The server trial in the held license; null without one, or while the license is unverified. */
744
+ getTrial(): TrialState | null;
603
745
  isFresh(): boolean;
604
746
  get(options?: {
605
747
  force?: boolean;
@@ -615,11 +757,13 @@ declare class EntitlementManager {
615
757
  stopAutoRefresh(): void;
616
758
  private scheduleDeadline;
617
759
  private schedule;
618
- private safePublicKey;
760
+ private measureClockSkew;
619
761
  private discard;
620
762
  private fingerprint;
621
763
  private notifyIfChanged;
622
764
  private offlineDeadline;
765
+ /** The signed allowance of the held license, or 48 hours when it names none. */
766
+ private offlineAgeMs;
623
767
  private snapshot;
624
768
  }
625
769
 
@@ -632,6 +776,8 @@ interface RecoveryManagerOptions {
632
776
  storage: StorageAdapter;
633
777
  publishableKey: string;
634
778
  onComplete: (endUserRef: string, envelope: SignedEntitlement) => Promise<Entitlement>;
779
+ /** Runs after `onComplete` accepted the entitlement, with the claim's storage grant (if any). */
780
+ onStorageGrant?: (grant: PayStorageGrant | undefined) => Promise<CloudBackupState | undefined>;
635
781
  openUrl?: (url: string) => void | Promise<void>;
636
782
  now?: () => number;
637
783
  }
@@ -665,13 +811,17 @@ declare class EventEmitter<Events extends object> {
665
811
  * extends it with `getOffer()` / `showPaywall()`.
666
812
  *
667
813
  * Data that leaves the extension: `publishableKey`, `endUserRef`, `sku`,
668
- * `locale` and checkout session IDs. Explicit recovery also sends its session ID,
669
- * challenge and claim secret (POST body). Email stays on the hosted page.
814
+ * `locale`, checkout session IDs and, with a server trial, the trial start date
815
+ * the server issued (`trialStartedHint`, kept in storage.sync). Explicit recovery also sends its session ID,
816
+ * challenge and claim secret (POST body). Email stays on the hosted page. With cloud backup, the
817
+ * storage token goes only to `/v1/storage` (as a bearer), never in a message to a content script.
670
818
  */
671
819
 
672
820
  /** Injection points for tests and unusual hosts. */
673
821
  interface ExtenshiPayDeps {
674
822
  storage?: StorageAdapter;
823
+ /** Where the trial start is synced (default `storage.sync`); null turns syncing off. */
824
+ syncStorage?: StorageAdapter | null;
675
825
  /** Trusted extension-only storage; never share this adapter with content scripts. */
676
826
  recoveryStorage?: StorageAdapter;
677
827
  transport?: Transport;
@@ -680,7 +830,7 @@ interface ExtenshiPayDeps {
680
830
  now?: () => number;
681
831
  }
682
832
  declare class ExtenshiPayLite {
683
- static readonly version = "0.9.0";
833
+ static readonly version = "0.12.0";
684
834
  protected readonly config: ResolvedConfig;
685
835
  protected readonly emitter: EventEmitter<ExtenshiPayEvents>;
686
836
  protected readonly storage: StorageAdapter;
@@ -688,11 +838,21 @@ declare class ExtenshiPayLite {
688
838
  protected readonly entitlements: EntitlementManager;
689
839
  protected readonly checkout: CheckoutManager;
690
840
  protected readonly recovery: RecoveryManager;
841
+ private readonly backup;
842
+ /** `deps.openUrl`, for tabs the full SDK opens outside checkout and recovery. */
843
+ protected readonly openUrl: ((url: string) => void | Promise<void>) | undefined;
844
+ private readonly trial;
845
+ /** storage.sync for the trial start; null when off, in mock mode, or outside an extension. */
846
+ private readonly syncStorage;
691
847
  private readonly now;
692
848
  private endUserRef;
693
849
  private endUserRefPromise;
694
850
  private offer;
695
851
  private offerInflight;
852
+ /** The signing key the server returned in this session; never one read from storage. */
853
+ private serverKey;
854
+ /** Trust order for license signatures; see payment/signature.ts. */
855
+ private readonly keys;
696
856
  private readyPromise;
697
857
  private destroyed;
698
858
  constructor(config: ExtenshiPayConfig, deps?: ExtenshiPayDeps);
@@ -709,6 +869,13 @@ declare class ExtenshiPayLite {
709
869
  getEndUserRef(): Promise<string>;
710
870
  getCachedEntitlement(): Entitlement | null;
711
871
  getEntitlement(options?: GetEntitlementOptions): Promise<Entitlement>;
872
+ /**
873
+ * The free trial the application set on the server, from the verified license, or null when
874
+ * there is none (or the license could not be verified yet). Answers offline from the cached
875
+ * license; like paid access, `active` needs a license check within 48 hours. `isPaid()` and
876
+ * `hasFeature()` do not include the trial: grant trial access with `(await getTrial())?.active`.
877
+ */
878
+ getTrial(options?: GetEntitlementOptions): Promise<TrialState | null>;
712
879
  /** True when any active/grace entitlement exists, or the given `sku` is active/grace. */
713
880
  isPaid(sku?: string): Promise<boolean>;
714
881
  hasFeature(feature: string): Promise<boolean>;
@@ -740,6 +907,23 @@ declare class ExtenshiPayLite {
740
907
  openCheckout(sku: string, options?: CheckoutOptions): Promise<CheckoutResult>;
741
908
  /** Opens email verification on the hosted page. No email is collected inside the extension. */
742
909
  restorePurchase(options?: RestoreOptions): Promise<RestoreResult>;
910
+ /**
911
+ * Turns on the cloud copy of the extension's settings (`@extenshi/storage`): the
912
+ * hosted restore page shows the storage disclosure and the buyer confirms with
913
+ * the code from the purchase email. `cloudBackup` in the result says whether it is
914
+ * on. Buyers only; consent is recorded by the server.
915
+ */
916
+ enableCloudBackup(options?: Omit<RestoreOptions, 'purpose'>): Promise<RestoreResult>;
917
+ /**
918
+ * The storage token for `ExtenshiStorage.create({ cloud: { getToken } })`, or null
919
+ * while cloud backup is off on this installation. Extension pages and background
920
+ * only: it rejects in a content script, and must never be sent to one.
921
+ */
922
+ cloudBackupToken(): Promise<string | null>;
923
+ /** Turns cloud backup off on this installation: revokes its token. The cloud copy stays. */
924
+ disableCloudBackup(): Promise<void>;
925
+ /** Deletes the buyer's cloud copy and turns cloud backup off on every installation. */
926
+ deleteCloudBackup(): Promise<void>;
743
927
  /** Read-only license view. Entitlements retain cache/signature/offline semantics. */
744
928
  getLicenseSummary(options?: GetEntitlementOptions): Promise<LicenseSummary>;
745
929
  /** Opens the provider's self-service portal; resolves null when the provider has none. */
@@ -753,12 +937,29 @@ declare class ExtenshiPayLite {
753
937
  destroy(): void;
754
938
  /** Offer + signing key. Public in the full SDK (`getOffer`), internal here. */
755
939
  protected fetchOffer(force?: boolean): Promise<PayOfferResponse>;
756
- private getPublicKey;
940
+ private get serverKeyStorageKey();
941
+ private readSavedServerKey;
942
+ /**
943
+ * Keeps the server's key next to the license cache so a restart with no network can verify it.
944
+ * Not with a bundled key: that one already covers the restart, and storage stays untrusted.
945
+ */
946
+ private rememberServerKey;
947
+ /**
948
+ * A license verified with the saved key alone is checked against the server once per start:
949
+ * when the server's key differs (rotation, or an edited storage) the license is fetched again,
950
+ * and dropped if it does not verify. Offline, the saved key stands until `offlineUntil`.
951
+ */
952
+ private confirmSavedServerKey;
953
+ private get trialStartKey();
954
+ /** The synced trial start, or null (none, malformed, or storage.sync unavailable). */
955
+ private readTrialStartHint;
956
+ /** Syncs the verified trial start, keeping the earliest one seen. Never the installation id. */
957
+ private rememberTrialStart;
757
958
  protected reportError(error: unknown): ExtenshiPayError;
758
959
  }
759
960
 
760
961
  /** Kept in sync with package.json by tests/unit/version.test.ts. */
761
- declare const VERSION = "0.9.0";
962
+ declare const VERSION = "0.12.0";
762
963
 
763
964
  export { ERROR_CODES, ExtenshiPayLite as ExtenshiPay, ExtenshiPayError, ExtenshiPayLite, MockTransport, PAY_WITHDRAWAL_WAIVER_VERSION, VERSION, ExtenshiPayLite as default };
764
- export type { CheckoutOptions, CheckoutResult, CheckoutState, CustomerPortalOptions, Entitlement, EntitlementSource, ErrorCode, ExtenshiPayConfig, ExtenshiPayDeps, ExtenshiPayEventName, ExtenshiPayEvents, GetEntitlementOptions, LicenseSummary, MockData, PayEntitlementItem, PayEntitlementStatus, PayOfferDto, PayPortalAccount, PayPortalResponse, PaySellerPublic, PayWithdrawalWaiver, RequireFeatureOptions, RestoreOptions, RestoreResult, StorageAdapter, ThemeConfig, Transport, WithdrawalWaiverConsent };
965
+ export type { CheckoutOptions, CheckoutResult, CheckoutState, ClockSkew, CloudBackupState, CustomerPortalOptions, Entitlement, EntitlementSource, ErrorCode, ExtenshiPayConfig, ExtenshiPayDeps, ExtenshiPayEventName, ExtenshiPayEvents, GetEntitlementOptions, LicenseSummary, MockData, PayEntitlementItem, PayEntitlementStatus, PayOfferDto, PayPortalAccount, PayPortalResponse, PayRestorePurpose, PaySellerPublic, PayStorageGrant, PayWithdrawalWaiver, RequireFeatureOptions, RestoreOptions, RestoreResult, StorageAdapter, ThemeConfig, Transport, TrialState, WithdrawalWaiverConsent };