@extenshi/pay 0.9.0 → 0.11.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 +128 -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 +268 -26
  14. package/dist/core.d.ts +268 -26
  15. package/dist/core.js +566 -44
  16. package/dist/core.js.map +1 -1
  17. package/dist/core.mjs +562 -45
  18. package/dist/core.mjs.map +1 -1
  19. package/dist/extenshi-pay-lite.js +555 -44
  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 +555 -44
  24. package/dist/extenshi-pay-lite.mjs.map +1 -1
  25. package/dist/extenshi-pay.cjs.js +670 -57
  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 +670 -57
  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 +666 -58
  36. package/dist/extenshi-pay.mjs.map +1 -1
  37. package/dist/index.d.mts +285 -26
  38. package/dist/index.d.ts +285 -26
  39. package/dist/lite.d.mts +212 -13
  40. package/dist/lite.d.ts +212 -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 +35 -0
  65. package/dist/types/contract.d.ts.map +1 -1
  66. package/dist/types/entitlement.d.ts +37 -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';
@@ -328,8 +386,33 @@ interface Entitlement {
328
386
  requiresOnlineCheck?: boolean;
329
387
  /** Local offline-access deadline; null for mock mode or no cached license. */
330
388
  offlineUntil?: number | null;
389
+ /**
390
+ * Set when the device clock differed from the server's by more than 5 minutes at the last
391
+ * license check. With `requiresOnlineCheck` on a connected device, ask the user to correct
392
+ * the date and time instead of asking them to connect.
393
+ */
394
+ clockSkew?: ClockSkew | null;
331
395
  source: EntitlementSource;
332
396
  }
397
+ interface ClockSkew {
398
+ /** `ahead`: the device clock is later than the server's. */
399
+ direction: 'ahead' | 'behind';
400
+ /** Size of the difference in milliseconds. */
401
+ ms: number;
402
+ }
403
+ /** `getTrial()`: the free trial from the verified license, on the server's clock. */
404
+ interface TrialState {
405
+ /** True while the trial runs and the license was checked within the last 48 hours, as for paid access. */
406
+ active: boolean;
407
+ /** ISO time of the installation's first license check while the application had a trial. */
408
+ startedAt: string;
409
+ /** ISO time the trial ends. */
410
+ endsAt: string;
411
+ /** Whole days left, rounded up; 0 once the trial has ended. */
412
+ daysLeft: number;
413
+ /** The trial has days left but the license was not checked within 48 hours: connect to resume it. */
414
+ requiresOnlineCheck: boolean;
415
+ }
333
416
  interface GetEntitlementOptions {
334
417
  /** Skip the cache TTL and hit the network. */
335
418
  force?: boolean;
@@ -385,10 +468,21 @@ interface RestoreOptions {
385
468
  pollIntervalMs?: number;
386
469
  signal?: AbortSignal;
387
470
  openUrl?: (url: string) => void | Promise<void>;
471
+ /**
472
+ * `storage` also turns on the cloud copy of settings: the hosted page shows
473
+ * the storage disclosure first. `enableCloudBackup()` passes it. Default: a plain restore.
474
+ */
475
+ purpose?: PayRestorePurpose;
388
476
  }
477
+ /**
478
+ * The cloud copy of settings after a completed restore: `on` (the token is
479
+ * stored), or why it is off. Absent when the application does not offer it.
480
+ */
481
+ type CloudBackupState = 'on' | 'no_consent' | 'license_required';
389
482
  type RestoreResult = {
390
483
  state: 'complete';
391
484
  entitlement: Entitlement;
485
+ cloudBackup?: CloudBackupState;
392
486
  } | {
393
487
  state: 'timeout' | 'expired' | 'canceled';
394
488
  };
@@ -440,11 +534,15 @@ declare class MockTransport implements Transport {
440
534
  private readonly checkoutEnabled;
441
535
  private readonly claimAfterPolls;
442
536
  private readonly withdrawalWaiver;
537
+ private readonly seller;
538
+ private trial;
443
539
  readonly sessions: Map<string, MockSession>;
444
540
  constructor(data?: MockData);
445
541
  call<T>(procedure: string, _kind: ProcedureKind, input: Record<string, unknown>): Promise<T>;
446
542
  /** Test/dev helpers. */
447
543
  setEntitlements(items: PayEntitlementItem[]): void;
544
+ /** Previews a server trial of `days` from `startedAt` (default now); `null` removes it. */
545
+ setTrial(days: number | null, startedAt?: string): void;
448
546
  cancelSession(sessionId: string): void;
449
547
  expireSession(sessionId: string): void;
450
548
  private offerResponse;
@@ -460,8 +558,12 @@ declare class PayApi {
460
558
  private readonly transport;
461
559
  private readonly publishableKey;
462
560
  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>;
561
+ /**
562
+ * `locale` opens the hosted recovery page (and its email) in the user's language.
563
+ * `purpose` is sent only for `storage`: a plain restore keeps the request older
564
+ * BFFs know, and their non-strict zod input strips the key anyway.
565
+ */
566
+ createRestoreSession(claimChallenge: string, locale?: string | null, purpose?: PayRestorePurpose): Promise<PayRestoreSessionResponse>;
465
567
  claimRestoreSession(sessionId: string, claimSecret: string): Promise<PayRestoreClaimResponse>;
466
568
  getOffer(locale?: string | null): Promise<PayOfferResponse>;
467
569
  /**
@@ -471,7 +573,8 @@ declare class PayApi {
471
573
  */
472
574
  createCheckout(sku: string, endUserRef: string, locale?: string | null, withdrawalWaiver?: WithdrawalWaiverConsent): Promise<PayCheckoutSession>;
473
575
  claimSession(sessionId: string, endUserRef: string): Promise<PayCheckoutClaim>;
474
- getEntitlement(endUserRef: string): Promise<SignedEntitlement>;
576
+ /** `trialStartedHint`: the trial start kept in storage.sync; the server only lets it move a start earlier. */
577
+ getEntitlement(endUserRef: string, trialStartedHint?: string | null): Promise<SignedEntitlement>;
475
578
  getPortalUrl(endUserRef: string, customerId?: string, locale?: string | null): Promise<PayPortalResponse>;
476
579
  }
477
580
 
@@ -512,6 +615,10 @@ interface ExtenshiPayEvents {
512
615
  sku: string;
513
616
  sessionId: string;
514
617
  };
618
+ /** Once per installation and trial, `trialEndingDays` before the end, while the user has no paid access. */
619
+ 'trial:ending': TrialState;
620
+ /** Once per installation and trial, when it has ended, while the user has no paid access. */
621
+ 'trial:ended': TrialState;
515
622
  error: ExtenshiPayError;
516
623
  }
517
624
  type ExtenshiPayEventName = keyof ExtenshiPayEvents;
@@ -555,13 +662,36 @@ declare class CheckoutManager {
555
662
  private settle;
556
663
  }
557
664
 
665
+ /**
666
+ * Ed25519 verification of the entitlement projection.
667
+ *
668
+ * Tamper resistance, not DRM. Callers must deny access for both invalid and
669
+ * unverified envelopes outside explicit mocks.
670
+ *
671
+ * Which keys are trusted, in order (`PublicKeySource`, built in core/extenshi-pay.ts):
672
+ * 1. the key the server returned over HTTPS in this session;
673
+ * 2. the bundled `entitlementPublicKey`, when the developer configured one. It pins
674
+ * verification without a round-trip: a key read from extension storage is then never used;
675
+ * 3. without a bundled key, the server key saved in `storage.local` next to the
676
+ * license cache, so a restart with no network can still verify the cache.
677
+ * When none of them verifies an envelope the server is asked for its current key once
678
+ * (a rotated key), and that answer decides.
679
+ */
680
+
681
+ interface PublicKeySource {
682
+ /** Keys trusted without a round-trip, in the order above. */
683
+ known(): Promise<string[]>;
684
+ /** The server's current key, fetched now; null when the server signs nothing. Rejects when unreachable. */
685
+ fetchCurrent(): Promise<string | null>;
686
+ }
687
+
558
688
  /**
559
689
  * Entitlement cache + refresh.
560
690
  *
561
691
  * The cached envelope is a cache OF the server projection, never a second
562
692
  * source of truth: it is verified when stored and re-verified on load (once
563
693
  * 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
694
+ * TTL holds, served after signed issuance for the signed `offlineSeconds` (48 hours when absent) when the network is down, and expired
565
695
  * locally by `expiresAt`. Background refresh polls at most every 15 minutes
566
696
  * and backs off exponentially on errors.
567
697
  */
@@ -573,9 +703,13 @@ interface EntitlementManagerOptions {
573
703
  cacheTtlMs: number;
574
704
  source?: EntitlementSource;
575
705
  getEndUserRef: () => Promise<string>;
576
- /** Base64 raw Ed25519 public key from `getOffer`, or null when unknown/unsigned. */
577
- getPublicKey: () => Promise<string | null>;
706
+ /** The trusted Ed25519 keys, in order, and how to ask the server for its current one. */
707
+ keys: PublicKeySource;
578
708
  onChange?: (entitlement: Entitlement) => void;
709
+ /** After every accepted envelope, changed or not (the trial is not part of `onChange`). */
710
+ onAccepted?: () => void;
711
+ /** The synced trial start to send with a refresh; null when there is none. */
712
+ getTrialStartHint?: () => Promise<string | null>;
579
713
  onError?: (error: ExtenshiPayError) => void;
580
714
  now?: () => number;
581
715
  }
@@ -583,6 +717,8 @@ declare class EntitlementManager {
583
717
  private readonly options;
584
718
  private held;
585
719
  private inflight;
720
+ /** Device clock against the server's at the last license check; null within 5 minutes. */
721
+ private clockSkew;
586
722
  private timer;
587
723
  private refreshGeneration;
588
724
  private deadlineTimer;
@@ -599,7 +735,11 @@ declare class EntitlementManager {
599
735
  load(): Promise<Entitlement | null>;
600
736
  /** Re-checks the loaded envelope against the project's key; discards it when the signature is invalid. */
601
737
  reverify(): Promise<void>;
738
+ /** The key the held license was verified with; null when there is none or it is unverified. */
739
+ get verifiedKey(): string | null;
602
740
  getCached(): Entitlement | null;
741
+ /** The server trial in the held license; null without one, or while the license is unverified. */
742
+ getTrial(): TrialState | null;
603
743
  isFresh(): boolean;
604
744
  get(options?: {
605
745
  force?: boolean;
@@ -615,11 +755,13 @@ declare class EntitlementManager {
615
755
  stopAutoRefresh(): void;
616
756
  private scheduleDeadline;
617
757
  private schedule;
618
- private safePublicKey;
758
+ private measureClockSkew;
619
759
  private discard;
620
760
  private fingerprint;
621
761
  private notifyIfChanged;
622
762
  private offlineDeadline;
763
+ /** The signed allowance of the held license, or 48 hours when it names none. */
764
+ private offlineAgeMs;
623
765
  private snapshot;
624
766
  }
625
767
 
@@ -632,6 +774,8 @@ interface RecoveryManagerOptions {
632
774
  storage: StorageAdapter;
633
775
  publishableKey: string;
634
776
  onComplete: (endUserRef: string, envelope: SignedEntitlement) => Promise<Entitlement>;
777
+ /** Runs after `onComplete` accepted the entitlement, with the claim's storage grant (if any). */
778
+ onStorageGrant?: (grant: PayStorageGrant | undefined) => Promise<CloudBackupState | undefined>;
635
779
  openUrl?: (url: string) => void | Promise<void>;
636
780
  now?: () => number;
637
781
  }
@@ -665,13 +809,17 @@ declare class EventEmitter<Events extends object> {
665
809
  * extends it with `getOffer()` / `showPaywall()`.
666
810
  *
667
811
  * 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.
812
+ * `locale`, checkout session IDs and, with a server trial, the trial start date
813
+ * the server issued (`trialStartedHint`, kept in storage.sync). Explicit recovery also sends its session ID,
814
+ * challenge and claim secret (POST body). Email stays on the hosted page. With cloud backup, the
815
+ * storage token goes only to `/v1/storage` (as a bearer), never in a message to a content script.
670
816
  */
671
817
 
672
818
  /** Injection points for tests and unusual hosts. */
673
819
  interface ExtenshiPayDeps {
674
820
  storage?: StorageAdapter;
821
+ /** Where the trial start is synced (default `storage.sync`); null turns syncing off. */
822
+ syncStorage?: StorageAdapter | null;
675
823
  /** Trusted extension-only storage; never share this adapter with content scripts. */
676
824
  recoveryStorage?: StorageAdapter;
677
825
  transport?: Transport;
@@ -680,7 +828,7 @@ interface ExtenshiPayDeps {
680
828
  now?: () => number;
681
829
  }
682
830
  declare class ExtenshiPayLite {
683
- static readonly version = "0.9.0";
831
+ static readonly version = "0.11.0";
684
832
  protected readonly config: ResolvedConfig;
685
833
  protected readonly emitter: EventEmitter<ExtenshiPayEvents>;
686
834
  protected readonly storage: StorageAdapter;
@@ -688,11 +836,21 @@ declare class ExtenshiPayLite {
688
836
  protected readonly entitlements: EntitlementManager;
689
837
  protected readonly checkout: CheckoutManager;
690
838
  protected readonly recovery: RecoveryManager;
839
+ private readonly backup;
840
+ /** `deps.openUrl`, for tabs the full SDK opens outside checkout and recovery. */
841
+ protected readonly openUrl: ((url: string) => void | Promise<void>) | undefined;
842
+ private readonly trial;
843
+ /** storage.sync for the trial start; null when off, in mock mode, or outside an extension. */
844
+ private readonly syncStorage;
691
845
  private readonly now;
692
846
  private endUserRef;
693
847
  private endUserRefPromise;
694
848
  private offer;
695
849
  private offerInflight;
850
+ /** The signing key the server returned in this session; never one read from storage. */
851
+ private serverKey;
852
+ /** Trust order for license signatures; see payment/signature.ts. */
853
+ private readonly keys;
696
854
  private readyPromise;
697
855
  private destroyed;
698
856
  constructor(config: ExtenshiPayConfig, deps?: ExtenshiPayDeps);
@@ -709,6 +867,13 @@ declare class ExtenshiPayLite {
709
867
  getEndUserRef(): Promise<string>;
710
868
  getCachedEntitlement(): Entitlement | null;
711
869
  getEntitlement(options?: GetEntitlementOptions): Promise<Entitlement>;
870
+ /**
871
+ * The free trial the application set on the server, from the verified license, or null when
872
+ * there is none (or the license could not be verified yet). Answers offline from the cached
873
+ * license; like paid access, `active` needs a license check within 48 hours. `isPaid()` and
874
+ * `hasFeature()` do not include the trial: grant trial access with `(await getTrial())?.active`.
875
+ */
876
+ getTrial(options?: GetEntitlementOptions): Promise<TrialState | null>;
712
877
  /** True when any active/grace entitlement exists, or the given `sku` is active/grace. */
713
878
  isPaid(sku?: string): Promise<boolean>;
714
879
  hasFeature(feature: string): Promise<boolean>;
@@ -740,6 +905,23 @@ declare class ExtenshiPayLite {
740
905
  openCheckout(sku: string, options?: CheckoutOptions): Promise<CheckoutResult>;
741
906
  /** Opens email verification on the hosted page. No email is collected inside the extension. */
742
907
  restorePurchase(options?: RestoreOptions): Promise<RestoreResult>;
908
+ /**
909
+ * Turns on the cloud copy of the extension's settings (`@extenshi/storage`): the
910
+ * hosted restore page shows the storage disclosure and the buyer confirms with
911
+ * the code from the purchase email. `cloudBackup` in the result says whether it is
912
+ * on. Buyers only; consent is recorded by the server.
913
+ */
914
+ enableCloudBackup(options?: Omit<RestoreOptions, 'purpose'>): Promise<RestoreResult>;
915
+ /**
916
+ * The storage token for `ExtenshiStorage.create({ cloud: { getToken } })`, or null
917
+ * while cloud backup is off on this installation. Extension pages and background
918
+ * only: it rejects in a content script, and must never be sent to one.
919
+ */
920
+ cloudBackupToken(): Promise<string | null>;
921
+ /** Turns cloud backup off on this installation: revokes its token. The cloud copy stays. */
922
+ disableCloudBackup(): Promise<void>;
923
+ /** Deletes the buyer's cloud copy and turns cloud backup off on every installation. */
924
+ deleteCloudBackup(): Promise<void>;
743
925
  /** Read-only license view. Entitlements retain cache/signature/offline semantics. */
744
926
  getLicenseSummary(options?: GetEntitlementOptions): Promise<LicenseSummary>;
745
927
  /** Opens the provider's self-service portal; resolves null when the provider has none. */
@@ -753,12 +935,29 @@ declare class ExtenshiPayLite {
753
935
  destroy(): void;
754
936
  /** Offer + signing key. Public in the full SDK (`getOffer`), internal here. */
755
937
  protected fetchOffer(force?: boolean): Promise<PayOfferResponse>;
756
- private getPublicKey;
938
+ private get serverKeyStorageKey();
939
+ private readSavedServerKey;
940
+ /**
941
+ * Keeps the server's key next to the license cache so a restart with no network can verify it.
942
+ * Not with a bundled key: that one already covers the restart, and storage stays untrusted.
943
+ */
944
+ private rememberServerKey;
945
+ /**
946
+ * A license verified with the saved key alone is checked against the server once per start:
947
+ * when the server's key differs (rotation, or an edited storage) the license is fetched again,
948
+ * and dropped if it does not verify. Offline, the saved key stands until `offlineUntil`.
949
+ */
950
+ private confirmSavedServerKey;
951
+ private get trialStartKey();
952
+ /** The synced trial start, or null (none, malformed, or storage.sync unavailable). */
953
+ private readTrialStartHint;
954
+ /** Syncs the verified trial start, keeping the earliest one seen. Never the installation id. */
955
+ private rememberTrialStart;
757
956
  protected reportError(error: unknown): ExtenshiPayError;
758
957
  }
759
958
 
760
959
  /** Kept in sync with package.json by tests/unit/version.test.ts. */
761
- declare const VERSION = "0.9.0";
960
+ declare const VERSION = "0.11.0";
762
961
 
763
962
  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 };
963
+ 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 };