@extenshi/pay 0.8.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.
- package/README.md +134 -19
- package/dist/api/mock.d.ts +4 -0
- package/dist/api/mock.d.ts.map +1 -1
- package/dist/api/pay-api.d.ts +9 -4
- package/dist/api/pay-api.d.ts.map +1 -1
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/extenshi-pay.d.ts +60 -5
- package/dist/core/extenshi-pay.d.ts.map +1 -1
- package/dist/core/index.d.ts +3 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/storage.d.ts +6 -0
- package/dist/core/storage.d.ts.map +1 -1
- package/dist/core.d.mts +280 -27
- package/dist/core.d.ts +280 -27
- package/dist/core.js +566 -44
- package/dist/core.js.map +1 -1
- package/dist/core.mjs +562 -45
- package/dist/core.mjs.map +1 -1
- package/dist/extenshi-pay-lite.js +555 -44
- package/dist/extenshi-pay-lite.js.map +1 -1
- package/dist/extenshi-pay-lite.min.js +3 -3
- package/dist/extenshi-pay-lite.min.js.map +1 -1
- package/dist/extenshi-pay-lite.mjs +555 -44
- package/dist/extenshi-pay-lite.mjs.map +1 -1
- package/dist/extenshi-pay.cjs.js +823 -69
- package/dist/extenshi-pay.cjs.js.map +1 -1
- package/dist/extenshi-pay.d.ts +11 -1
- package/dist/extenshi-pay.d.ts.map +1 -1
- package/dist/extenshi-pay.js +823 -69
- package/dist/extenshi-pay.js.map +1 -1
- package/dist/extenshi-pay.min.js +3 -3
- package/dist/extenshi-pay.min.js.map +1 -1
- package/dist/extenshi-pay.min.mjs +3 -3
- package/dist/extenshi-pay.min.mjs.map +1 -1
- package/dist/extenshi-pay.mjs +819 -70
- package/dist/extenshi-pay.mjs.map +1 -1
- package/dist/index.d.mts +305 -27
- package/dist/index.d.ts +305 -27
- package/dist/lite.d.mts +224 -14
- package/dist/lite.d.ts +224 -14
- package/dist/lite.d.ts.map +1 -1
- package/dist/payment/cloud-backup.d.ts +35 -0
- package/dist/payment/cloud-backup.d.ts.map +1 -0
- package/dist/payment/entitlement.d.ts +21 -5
- package/dist/payment/entitlement.d.ts.map +1 -1
- package/dist/payment/recovery.d.ts +4 -2
- package/dist/payment/recovery.d.ts.map +1 -1
- package/dist/payment/signature.d.ts +29 -3
- package/dist/payment/signature.d.ts.map +1 -1
- package/dist/payment/trial.d.ts +55 -0
- package/dist/payment/trial.d.ts.map +1 -0
- package/dist/paywall/i18n.d.ts +3 -0
- package/dist/paywall/i18n.d.ts.map +1 -1
- package/dist/paywall/icon.d.ts +18 -0
- package/dist/paywall/icon.d.ts.map +1 -0
- package/dist/paywall/renderer.d.ts +15 -0
- package/dist/paywall/renderer.d.ts.map +1 -1
- package/dist/paywall.d.mts +27 -1
- package/dist/paywall.d.ts +27 -1
- package/dist/paywall.js +131 -25
- package/dist/paywall.js.map +1 -1
- package/dist/paywall.mjs +131 -25
- package/dist/paywall.mjs.map +1 -1
- package/dist/types/config.d.ts +27 -1
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/contract.d.ts +35 -0
- package/dist/types/contract.d.ts.map +1 -1
- package/dist/types/entitlement.d.ts +37 -1
- package/dist/types/entitlement.d.ts.map +1 -1
- package/dist/types/events.d.ts +5 -1
- package/dist/types/events.d.ts.map +1 -1
- package/dist/types/paywall.d.ts +22 -1
- package/dist/types/paywall.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.d.ts.map +1 -1
- package/package.json +3 -2
package/dist/lite.d.ts
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';
|
|
@@ -289,10 +347,21 @@ interface PaywallOptions {
|
|
|
289
347
|
sku?: string;
|
|
290
348
|
title?: string;
|
|
291
349
|
description?: string;
|
|
292
|
-
/**
|
|
350
|
+
/**
|
|
351
|
+
* Bullet points, in the user's language (`chrome.i18n.getMessage`). The
|
|
352
|
+
* offer's `features[]` are entitlement keys and are never shown: without
|
|
353
|
+
* this option the paywall has no feature list.
|
|
354
|
+
*/
|
|
293
355
|
features?: string[];
|
|
294
356
|
/** Free-tier bullets for the comparison templates (`inline`, `fullscreen`). */
|
|
295
357
|
freeFeatures?: string[];
|
|
358
|
+
/**
|
|
359
|
+
* Header image in place of the template's glyph: a path inside the
|
|
360
|
+
* extension (`icons/icon128.png`) or a `data:image/` URL. Defaults to the
|
|
361
|
+
* largest `manifest.icons` entry on the extension's own pages (popup,
|
|
362
|
+
* options); `false` keeps the glyph. Remote URLs are ignored.
|
|
363
|
+
*/
|
|
364
|
+
icon?: string | false;
|
|
296
365
|
theme?: ThemeConfig;
|
|
297
366
|
/** Mount point for `inline` mode (default `document.body`). */
|
|
298
367
|
container?: HTMLElement;
|
|
@@ -317,8 +386,33 @@ interface Entitlement {
|
|
|
317
386
|
requiresOnlineCheck?: boolean;
|
|
318
387
|
/** Local offline-access deadline; null for mock mode or no cached license. */
|
|
319
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;
|
|
320
395
|
source: EntitlementSource;
|
|
321
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
|
+
}
|
|
322
416
|
interface GetEntitlementOptions {
|
|
323
417
|
/** Skip the cache TTL and hit the network. */
|
|
324
418
|
force?: boolean;
|
|
@@ -374,10 +468,21 @@ interface RestoreOptions {
|
|
|
374
468
|
pollIntervalMs?: number;
|
|
375
469
|
signal?: AbortSignal;
|
|
376
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;
|
|
377
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';
|
|
378
482
|
type RestoreResult = {
|
|
379
483
|
state: 'complete';
|
|
380
484
|
entitlement: Entitlement;
|
|
485
|
+
cloudBackup?: CloudBackupState;
|
|
381
486
|
} | {
|
|
382
487
|
state: 'timeout' | 'expired' | 'canceled';
|
|
383
488
|
};
|
|
@@ -429,11 +534,15 @@ declare class MockTransport implements Transport {
|
|
|
429
534
|
private readonly checkoutEnabled;
|
|
430
535
|
private readonly claimAfterPolls;
|
|
431
536
|
private readonly withdrawalWaiver;
|
|
537
|
+
private readonly seller;
|
|
538
|
+
private trial;
|
|
432
539
|
readonly sessions: Map<string, MockSession>;
|
|
433
540
|
constructor(data?: MockData);
|
|
434
541
|
call<T>(procedure: string, _kind: ProcedureKind, input: Record<string, unknown>): Promise<T>;
|
|
435
542
|
/** Test/dev helpers. */
|
|
436
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;
|
|
437
546
|
cancelSession(sessionId: string): void;
|
|
438
547
|
expireSession(sessionId: string): void;
|
|
439
548
|
private offerResponse;
|
|
@@ -449,8 +558,12 @@ declare class PayApi {
|
|
|
449
558
|
private readonly transport;
|
|
450
559
|
private readonly publishableKey;
|
|
451
560
|
constructor(transport: Transport, publishableKey: string);
|
|
452
|
-
/**
|
|
453
|
-
|
|
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>;
|
|
454
567
|
claimRestoreSession(sessionId: string, claimSecret: string): Promise<PayRestoreClaimResponse>;
|
|
455
568
|
getOffer(locale?: string | null): Promise<PayOfferResponse>;
|
|
456
569
|
/**
|
|
@@ -460,7 +573,8 @@ declare class PayApi {
|
|
|
460
573
|
*/
|
|
461
574
|
createCheckout(sku: string, endUserRef: string, locale?: string | null, withdrawalWaiver?: WithdrawalWaiverConsent): Promise<PayCheckoutSession>;
|
|
462
575
|
claimSession(sessionId: string, endUserRef: string): Promise<PayCheckoutClaim>;
|
|
463
|
-
|
|
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>;
|
|
464
578
|
getPortalUrl(endUserRef: string, customerId?: string, locale?: string | null): Promise<PayPortalResponse>;
|
|
465
579
|
}
|
|
466
580
|
|
|
@@ -501,6 +615,10 @@ interface ExtenshiPayEvents {
|
|
|
501
615
|
sku: string;
|
|
502
616
|
sessionId: string;
|
|
503
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;
|
|
504
622
|
error: ExtenshiPayError;
|
|
505
623
|
}
|
|
506
624
|
type ExtenshiPayEventName = keyof ExtenshiPayEvents;
|
|
@@ -544,13 +662,36 @@ declare class CheckoutManager {
|
|
|
544
662
|
private settle;
|
|
545
663
|
}
|
|
546
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
|
+
|
|
547
688
|
/**
|
|
548
689
|
* Entitlement cache + refresh.
|
|
549
690
|
*
|
|
550
691
|
* The cached envelope is a cache OF the server projection, never a second
|
|
551
692
|
* source of truth: it is verified when stored and re-verified on load (once
|
|
552
693
|
* the project's public key is known), served without a round-trip while the
|
|
553
|
-
* TTL holds, served for
|
|
694
|
+
* TTL holds, served after signed issuance for the signed `offlineSeconds` (48 hours when absent) when the network is down, and expired
|
|
554
695
|
* locally by `expiresAt`. Background refresh polls at most every 15 minutes
|
|
555
696
|
* and backs off exponentially on errors.
|
|
556
697
|
*/
|
|
@@ -562,9 +703,13 @@ interface EntitlementManagerOptions {
|
|
|
562
703
|
cacheTtlMs: number;
|
|
563
704
|
source?: EntitlementSource;
|
|
564
705
|
getEndUserRef: () => Promise<string>;
|
|
565
|
-
/**
|
|
566
|
-
|
|
706
|
+
/** The trusted Ed25519 keys, in order, and how to ask the server for its current one. */
|
|
707
|
+
keys: PublicKeySource;
|
|
567
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>;
|
|
568
713
|
onError?: (error: ExtenshiPayError) => void;
|
|
569
714
|
now?: () => number;
|
|
570
715
|
}
|
|
@@ -572,6 +717,8 @@ declare class EntitlementManager {
|
|
|
572
717
|
private readonly options;
|
|
573
718
|
private held;
|
|
574
719
|
private inflight;
|
|
720
|
+
/** Device clock against the server's at the last license check; null within 5 minutes. */
|
|
721
|
+
private clockSkew;
|
|
575
722
|
private timer;
|
|
576
723
|
private refreshGeneration;
|
|
577
724
|
private deadlineTimer;
|
|
@@ -588,7 +735,11 @@ declare class EntitlementManager {
|
|
|
588
735
|
load(): Promise<Entitlement | null>;
|
|
589
736
|
/** Re-checks the loaded envelope against the project's key; discards it when the signature is invalid. */
|
|
590
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;
|
|
591
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;
|
|
592
743
|
isFresh(): boolean;
|
|
593
744
|
get(options?: {
|
|
594
745
|
force?: boolean;
|
|
@@ -604,11 +755,13 @@ declare class EntitlementManager {
|
|
|
604
755
|
stopAutoRefresh(): void;
|
|
605
756
|
private scheduleDeadline;
|
|
606
757
|
private schedule;
|
|
607
|
-
private
|
|
758
|
+
private measureClockSkew;
|
|
608
759
|
private discard;
|
|
609
760
|
private fingerprint;
|
|
610
761
|
private notifyIfChanged;
|
|
611
762
|
private offlineDeadline;
|
|
763
|
+
/** The signed allowance of the held license, or 48 hours when it names none. */
|
|
764
|
+
private offlineAgeMs;
|
|
612
765
|
private snapshot;
|
|
613
766
|
}
|
|
614
767
|
|
|
@@ -621,6 +774,8 @@ interface RecoveryManagerOptions {
|
|
|
621
774
|
storage: StorageAdapter;
|
|
622
775
|
publishableKey: string;
|
|
623
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>;
|
|
624
779
|
openUrl?: (url: string) => void | Promise<void>;
|
|
625
780
|
now?: () => number;
|
|
626
781
|
}
|
|
@@ -654,13 +809,17 @@ declare class EventEmitter<Events extends object> {
|
|
|
654
809
|
* extends it with `getOffer()` / `showPaywall()`.
|
|
655
810
|
*
|
|
656
811
|
* Data that leaves the extension: `publishableKey`, `endUserRef`, `sku`,
|
|
657
|
-
* `locale
|
|
658
|
-
*
|
|
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.
|
|
659
816
|
*/
|
|
660
817
|
|
|
661
818
|
/** Injection points for tests and unusual hosts. */
|
|
662
819
|
interface ExtenshiPayDeps {
|
|
663
820
|
storage?: StorageAdapter;
|
|
821
|
+
/** Where the trial start is synced (default `storage.sync`); null turns syncing off. */
|
|
822
|
+
syncStorage?: StorageAdapter | null;
|
|
664
823
|
/** Trusted extension-only storage; never share this adapter with content scripts. */
|
|
665
824
|
recoveryStorage?: StorageAdapter;
|
|
666
825
|
transport?: Transport;
|
|
@@ -669,7 +828,7 @@ interface ExtenshiPayDeps {
|
|
|
669
828
|
now?: () => number;
|
|
670
829
|
}
|
|
671
830
|
declare class ExtenshiPayLite {
|
|
672
|
-
static readonly version = "0.
|
|
831
|
+
static readonly version = "0.11.0";
|
|
673
832
|
protected readonly config: ResolvedConfig;
|
|
674
833
|
protected readonly emitter: EventEmitter<ExtenshiPayEvents>;
|
|
675
834
|
protected readonly storage: StorageAdapter;
|
|
@@ -677,11 +836,21 @@ declare class ExtenshiPayLite {
|
|
|
677
836
|
protected readonly entitlements: EntitlementManager;
|
|
678
837
|
protected readonly checkout: CheckoutManager;
|
|
679
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;
|
|
680
845
|
private readonly now;
|
|
681
846
|
private endUserRef;
|
|
682
847
|
private endUserRefPromise;
|
|
683
848
|
private offer;
|
|
684
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;
|
|
685
854
|
private readyPromise;
|
|
686
855
|
private destroyed;
|
|
687
856
|
constructor(config: ExtenshiPayConfig, deps?: ExtenshiPayDeps);
|
|
@@ -698,6 +867,13 @@ declare class ExtenshiPayLite {
|
|
|
698
867
|
getEndUserRef(): Promise<string>;
|
|
699
868
|
getCachedEntitlement(): Entitlement | null;
|
|
700
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>;
|
|
701
877
|
/** True when any active/grace entitlement exists, or the given `sku` is active/grace. */
|
|
702
878
|
isPaid(sku?: string): Promise<boolean>;
|
|
703
879
|
hasFeature(feature: string): Promise<boolean>;
|
|
@@ -729,6 +905,23 @@ declare class ExtenshiPayLite {
|
|
|
729
905
|
openCheckout(sku: string, options?: CheckoutOptions): Promise<CheckoutResult>;
|
|
730
906
|
/** Opens email verification on the hosted page. No email is collected inside the extension. */
|
|
731
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>;
|
|
732
925
|
/** Read-only license view. Entitlements retain cache/signature/offline semantics. */
|
|
733
926
|
getLicenseSummary(options?: GetEntitlementOptions): Promise<LicenseSummary>;
|
|
734
927
|
/** Opens the provider's self-service portal; resolves null when the provider has none. */
|
|
@@ -742,12 +935,29 @@ declare class ExtenshiPayLite {
|
|
|
742
935
|
destroy(): void;
|
|
743
936
|
/** Offer + signing key. Public in the full SDK (`getOffer`), internal here. */
|
|
744
937
|
protected fetchOffer(force?: boolean): Promise<PayOfferResponse>;
|
|
745
|
-
private
|
|
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;
|
|
746
956
|
protected reportError(error: unknown): ExtenshiPayError;
|
|
747
957
|
}
|
|
748
958
|
|
|
749
959
|
/** Kept in sync with package.json by tests/unit/version.test.ts. */
|
|
750
|
-
declare const VERSION = "0.
|
|
960
|
+
declare const VERSION = "0.11.0";
|
|
751
961
|
|
|
752
962
|
export { ERROR_CODES, ExtenshiPayLite as ExtenshiPay, ExtenshiPayError, ExtenshiPayLite, MockTransport, PAY_WITHDRAWAL_WAIVER_VERSION, VERSION, ExtenshiPayLite as default };
|
|
753
|
-
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 };
|
package/dist/lite.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lite.d.ts","sourceRoot":"","sources":["../src/lite.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAC7C,YAAY,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AACnD,YAAY,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,EAAE,eAAe,EAAE,eAAe,IAAI,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACxF,YAAY,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAEvD,OAAO,EAAE,6BAA6B,EAAE,MAAM,qBAAqB,CAAA;AACnE,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AACjE,YAAY,EACX,eAAe,EACf,cAAc,EACd,aAAa,EACb,qBAAqB,EACrB,WAAW,EACX,iBAAiB,EACjB,SAAS,EACT,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EACjB,qBAAqB,EACrB,cAAc,EACd,QAAQ,EACR,kBAAkB,EAClB,oBAAoB,EACpB,WAAW,EACX,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,EACf,mBAAmB,EACnB,qBAAqB,EACrB,cAAc,EACd,aAAa,EACb,WAAW,EACX,uBAAuB,GACvB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAEtC,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACxD,eAAe,eAAe,CAAA"}
|
|
1
|
+
{"version":3,"file":"lite.d.ts","sourceRoot":"","sources":["../src/lite.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAC7C,YAAY,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AACnD,YAAY,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,EAAE,eAAe,EAAE,eAAe,IAAI,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACxF,YAAY,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAEvD,OAAO,EAAE,6BAA6B,EAAE,MAAM,qBAAqB,CAAA;AACnE,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AACjE,YAAY,EACX,eAAe,EACf,cAAc,EACd,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,qBAAqB,EACrB,WAAW,EACX,iBAAiB,EACjB,SAAS,EACT,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EACjB,qBAAqB,EACrB,cAAc,EACd,QAAQ,EACR,kBAAkB,EAClB,oBAAoB,EACpB,WAAW,EACX,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,mBAAmB,EACnB,qBAAqB,EACrB,cAAc,EACd,aAAa,EACb,WAAW,EACX,UAAU,EACV,uBAAuB,GACvB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAEtC,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACxD,eAAe,eAAe,CAAA"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cloud copy of the extension's settings (`@extenshi/storage`). Pay owns the
|
|
3
|
+
* token: only a verified restore claim issues it; this module keeps it in the
|
|
4
|
+
* SDK's storage (`storage.local`) and revokes it. `@extenshi/storage` reads it
|
|
5
|
+
* through `cloudBackupToken()`. The token is never logged and never answered to
|
|
6
|
+
* a content script: route those calls to the background.
|
|
7
|
+
*/
|
|
8
|
+
import type { StorageAdapter } from '../core/storage.js';
|
|
9
|
+
import { type PayStorageGrant } from '../types/contract.js';
|
|
10
|
+
import type { CloudBackupState } from '../types/entitlement.js';
|
|
11
|
+
export interface CloudBackupOptions {
|
|
12
|
+
storage: StorageAdapter;
|
|
13
|
+
publishableKey: string;
|
|
14
|
+
apiUrl: string;
|
|
15
|
+
fetch?: typeof fetch;
|
|
16
|
+
/** Mock mode: forget the token locally, never call the network. */
|
|
17
|
+
mock?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export declare class CloudBackup {
|
|
20
|
+
private readonly options;
|
|
21
|
+
private readonly fetchImpl;
|
|
22
|
+
constructor(options: CloudBackupOptions);
|
|
23
|
+
get storageKey(): string;
|
|
24
|
+
/** Stores or clears the token from a verified claim. Never throws: the licence is already restored. */
|
|
25
|
+
accept(grant: PayStorageGrant | undefined): Promise<CloudBackupState | undefined>;
|
|
26
|
+
token(): Promise<string | null>;
|
|
27
|
+
/** Revokes this installation's token. A token the server no longer knows (401) is forgotten too. */
|
|
28
|
+
disable(): Promise<void>;
|
|
29
|
+
/** Deletes the buyer's cloud copy and turns the backup off on every device. */
|
|
30
|
+
delete(): Promise<void>;
|
|
31
|
+
private assertTrustedContext;
|
|
32
|
+
private throwUnlessOk;
|
|
33
|
+
private request;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=cloud-backup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloud-backup.d.ts","sourceRoot":"","sources":["../../src/payment/cloud-backup.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACxD,OAAO,EAAE,KAAK,eAAe,EAAoB,MAAM,sBAAsB,CAAA;AAC7E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAM/D,MAAM,WAAW,kBAAkB;IAClC,OAAO,EAAE,cAAc,CAAA;IACvB,cAAc,EAAE,MAAM,CAAA;IACtB,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,OAAO,KAAK,CAAA;IACpB,mEAAmE;IACnE,IAAI,CAAC,EAAE,OAAO,CAAA;CACd;AAWD,qBAAa,WAAW;IAGX,OAAO,CAAC,QAAQ,CAAC,OAAO;IAFpC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAc;gBAEX,OAAO,EAAE,kBAAkB;IAIxD,IAAI,UAAU,IAAI,MAAM,CAEvB;IAED,uGAAuG;IACjG,MAAM,CAAC,KAAK,EAAE,eAAe,GAAG,SAAS,GAAG,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC;IAkBjF,KAAK,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAMrC,oGAAoG;IAC9F,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAU9B,+EAA+E;IACzE,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAuB7B,OAAO,CAAC,oBAAoB;IAQ5B,OAAO,CAAC,aAAa;YASP,OAAO;CAmBrB"}
|
|
@@ -4,18 +4,22 @@
|
|
|
4
4
|
* The cached envelope is a cache OF the server projection, never a second
|
|
5
5
|
* source of truth: it is verified when stored and re-verified on load (once
|
|
6
6
|
* the project's public key is known), served without a round-trip while the
|
|
7
|
-
* TTL holds, served for
|
|
7
|
+
* TTL holds, served after signed issuance for the signed `offlineSeconds` (48 hours when absent) when the network is down, and expired
|
|
8
8
|
* locally by `expiresAt`. Background refresh polls at most every 15 minutes
|
|
9
9
|
* and backs off exponentially on errors.
|
|
10
10
|
*/
|
|
11
11
|
import type { PayApi } from '../api/pay-api.js';
|
|
12
12
|
import type { StorageAdapter } from '../core/storage.js';
|
|
13
13
|
import { type SignedEntitlement } from '../types/contract.js';
|
|
14
|
-
import type { Entitlement, EntitlementSource } from '../types/entitlement.js';
|
|
14
|
+
import type { Entitlement, EntitlementSource, TrialState } from '../types/entitlement.js';
|
|
15
15
|
import { ExtenshiPayError } from '../types/errors.js';
|
|
16
|
+
import { type PublicKeySource } from './signature.js';
|
|
16
17
|
export declare const MIN_REFRESH_INTERVAL_MS: number;
|
|
17
18
|
export declare const MAX_REFRESH_BACKOFF_MS: number;
|
|
19
|
+
/** Offline allowance when the signed license names none (older servers and caches). */
|
|
18
20
|
export declare const MAX_OFFLINE_AGE_MS: number;
|
|
21
|
+
/** Ceiling for a signed `offlineSeconds`. */
|
|
22
|
+
export declare const MAX_SIGNED_OFFLINE_AGE_MS: number;
|
|
19
23
|
export declare const MAX_CLOCK_SKEW_MS: number;
|
|
20
24
|
export interface EntitlementManagerOptions {
|
|
21
25
|
api: PayApi;
|
|
@@ -24,9 +28,13 @@ export interface EntitlementManagerOptions {
|
|
|
24
28
|
cacheTtlMs: number;
|
|
25
29
|
source?: EntitlementSource;
|
|
26
30
|
getEndUserRef: () => Promise<string>;
|
|
27
|
-
/**
|
|
28
|
-
|
|
31
|
+
/** The trusted Ed25519 keys, in order, and how to ask the server for its current one. */
|
|
32
|
+
keys: PublicKeySource;
|
|
29
33
|
onChange?: (entitlement: Entitlement) => void;
|
|
34
|
+
/** After every accepted envelope, changed or not (the trial is not part of `onChange`). */
|
|
35
|
+
onAccepted?: () => void;
|
|
36
|
+
/** The synced trial start to send with a refresh; null when there is none. */
|
|
37
|
+
getTrialStartHint?: () => Promise<string | null>;
|
|
30
38
|
onError?: (error: ExtenshiPayError) => void;
|
|
31
39
|
now?: () => number;
|
|
32
40
|
}
|
|
@@ -34,6 +42,8 @@ export declare class EntitlementManager {
|
|
|
34
42
|
private readonly options;
|
|
35
43
|
private held;
|
|
36
44
|
private inflight;
|
|
45
|
+
/** Device clock against the server's at the last license check; null within 5 minutes. */
|
|
46
|
+
private clockSkew;
|
|
37
47
|
private timer;
|
|
38
48
|
private refreshGeneration;
|
|
39
49
|
private deadlineTimer;
|
|
@@ -50,7 +60,11 @@ export declare class EntitlementManager {
|
|
|
50
60
|
load(): Promise<Entitlement | null>;
|
|
51
61
|
/** Re-checks the loaded envelope against the project's key; discards it when the signature is invalid. */
|
|
52
62
|
reverify(): Promise<void>;
|
|
63
|
+
/** The key the held license was verified with; null when there is none or it is unverified. */
|
|
64
|
+
get verifiedKey(): string | null;
|
|
53
65
|
getCached(): Entitlement | null;
|
|
66
|
+
/** The server trial in the held license; null without one, or while the license is unverified. */
|
|
67
|
+
getTrial(): TrialState | null;
|
|
54
68
|
isFresh(): boolean;
|
|
55
69
|
get(options?: {
|
|
56
70
|
force?: boolean;
|
|
@@ -66,11 +80,13 @@ export declare class EntitlementManager {
|
|
|
66
80
|
stopAutoRefresh(): void;
|
|
67
81
|
private scheduleDeadline;
|
|
68
82
|
private schedule;
|
|
69
|
-
private
|
|
83
|
+
private measureClockSkew;
|
|
70
84
|
private discard;
|
|
71
85
|
private fingerprint;
|
|
72
86
|
private notifyIfChanged;
|
|
73
87
|
private offlineDeadline;
|
|
88
|
+
/** The signed allowance of the held license, or 48 hours when it names none. */
|
|
89
|
+
private offlineAgeMs;
|
|
74
90
|
private snapshot;
|
|
75
91
|
}
|
|
76
92
|
//# sourceMappingURL=entitlement.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entitlement.d.ts","sourceRoot":"","sources":["../../src/payment/entitlement.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACxD,OAAO,EAAiB,KAAK,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAC5E,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"entitlement.d.ts","sourceRoot":"","sources":["../../src/payment/entitlement.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB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gBAAgB,CAAC,UAAU,GAAE,MAAmE,GAAG,IAAI;IASvG,eAAe,IAAI,IAAI;IAUvB,OAAO,CAAC,gBAAgB;IAwBxB,OAAO,CAAC,QAAQ;IAoBhB,OAAO,CAAC,gBAAgB;YAQV,OAAO;IAOrB,OAAO,CAAC,WAAW;IAKnB,OAAO,CAAC,eAAe;IAOvB,OAAO,CAAC,eAAe;IAQvB,gFAAgF;IAChF,OAAO,CAAC,YAAY;IAMpB,OAAO,CAAC,QAAQ;CAqChB"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/** Email stays on the hosted page. Only this extension context holds the claim secret. */
|
|
2
2
|
import type { PayApi } from '../api/pay-api.js';
|
|
3
3
|
import type { StorageAdapter } from '../core/storage.js';
|
|
4
|
-
import type { SignedEntitlement } from '../types/contract.js';
|
|
5
|
-
import type { Entitlement, RestoreOptions, RestoreResult } from '../types/entitlement.js';
|
|
4
|
+
import type { PayStorageGrant, SignedEntitlement } from '../types/contract.js';
|
|
5
|
+
import type { CloudBackupState, Entitlement, RestoreOptions, RestoreResult } from '../types/entitlement.js';
|
|
6
6
|
/** storage.local is exposed to content scripts by default. Never put a recovery proof there. */
|
|
7
7
|
export declare function createRecoveryStorage(): StorageAdapter;
|
|
8
8
|
export interface RecoveryManagerOptions {
|
|
@@ -12,6 +12,8 @@ export interface RecoveryManagerOptions {
|
|
|
12
12
|
storage: StorageAdapter;
|
|
13
13
|
publishableKey: string;
|
|
14
14
|
onComplete: (endUserRef: string, envelope: SignedEntitlement) => Promise<Entitlement>;
|
|
15
|
+
/** Runs after `onComplete` accepted the entitlement, with the claim's storage grant (if any). */
|
|
16
|
+
onStorageGrant?: (grant: PayStorageGrant | undefined) => Promise<CloudBackupState | undefined>;
|
|
15
17
|
openUrl?: (url: string) => void | Promise<void>;
|
|
16
18
|
now?: () => number;
|
|
17
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recovery.d.ts","sourceRoot":"","sources":["../../src/payment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