@extenshi/pay 0.7.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/LICENSE +21 -0
- package/README.md +260 -0
- package/dist/api/mock.d.ts +35 -0
- package/dist/api/mock.d.ts.map +1 -0
- package/dist/api/pay-api.d.ts +16 -0
- package/dist/api/pay-api.d.ts.map +1 -0
- package/dist/api/transport.d.ts +52 -0
- package/dist/api/transport.d.ts.map +1 -0
- package/dist/core/config.d.ts +5 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/event-emitter.d.ts +10 -0
- package/dist/core/event-emitter.d.ts.map +1 -0
- package/dist/core/extenshi-pay.d.ts +90 -0
- package/dist/core/extenshi-pay.d.ts.map +1 -0
- package/dist/core/identity.d.ts +13 -0
- package/dist/core/identity.d.ts.map +1 -0
- package/dist/core/index.d.ts +25 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/storage.d.ts +42 -0
- package/dist/core/storage.d.ts.map +1 -0
- package/dist/core.d.mts +821 -0
- package/dist/core.d.ts +821 -0
- package/dist/core.esm.js +1681 -0
- package/dist/core.esm.js.map +1 -0
- package/dist/core.js +1806 -0
- package/dist/core.js.map +1 -0
- package/dist/core.mjs +1744 -0
- package/dist/core.mjs.map +1 -0
- package/dist/extenshi-pay-lite.esm.js +1664 -0
- package/dist/extenshi-pay-lite.esm.js.map +1 -0
- package/dist/extenshi-pay-lite.js +1743 -0
- package/dist/extenshi-pay-lite.js.map +1 -0
- package/dist/extenshi-pay-lite.min.js +7 -0
- package/dist/extenshi-pay-lite.min.js.map +1 -0
- package/dist/extenshi-pay-lite.mjs +1727 -0
- package/dist/extenshi-pay-lite.mjs.map +1 -0
- package/dist/extenshi-pay.cjs.js +2632 -0
- package/dist/extenshi-pay.cjs.js.map +1 -0
- package/dist/extenshi-pay.d.ts +32 -0
- package/dist/extenshi-pay.d.ts.map +1 -0
- package/dist/extenshi-pay.esm.js +2496 -0
- package/dist/extenshi-pay.esm.js.map +1 -0
- package/dist/extenshi-pay.esm.min.js +7 -0
- package/dist/extenshi-pay.esm.min.js.map +1 -0
- package/dist/extenshi-pay.js +2638 -0
- package/dist/extenshi-pay.js.map +1 -0
- package/dist/extenshi-pay.min.js +7 -0
- package/dist/extenshi-pay.min.js.map +1 -0
- package/dist/extenshi-pay.min.mjs +7 -0
- package/dist/extenshi-pay.min.mjs.map +1 -0
- package/dist/extenshi-pay.mjs +2559 -0
- package/dist/extenshi-pay.mjs.map +1 -0
- package/dist/index.d.mts +937 -0
- package/dist/index.d.ts +937 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/lite.d.mts +659 -0
- package/dist/lite.d.ts +659 -0
- package/dist/lite.d.ts.map +1 -0
- package/dist/payment/checkout.d.ts +47 -0
- package/dist/payment/checkout.d.ts.map +1 -0
- package/dist/payment/entitlement.d.ts +76 -0
- package/dist/payment/entitlement.d.ts.map +1 -0
- package/dist/payment/features.d.ts +12 -0
- package/dist/payment/features.d.ts.map +1 -0
- package/dist/payment/recovery.d.ts +29 -0
- package/dist/payment/recovery.d.ts.map +1 -0
- package/dist/payment/signature.d.ts +12 -0
- package/dist/payment/signature.d.ts.map +1 -0
- package/dist/paywall/billing-profile-picker.d.ts +8 -0
- package/dist/paywall/billing-profile-picker.d.ts.map +1 -0
- package/dist/paywall/format.d.ts +13 -0
- package/dist/paywall/format.d.ts.map +1 -0
- package/dist/paywall/index.d.ts +9 -0
- package/dist/paywall/index.d.ts.map +1 -0
- package/dist/paywall/license-panel.d.ts +10 -0
- package/dist/paywall/license-panel.d.ts.map +1 -0
- package/dist/paywall/renderer.d.ts +55 -0
- package/dist/paywall/renderer.d.ts.map +1 -0
- package/dist/paywall/seller-details.d.ts +5 -0
- package/dist/paywall/seller-details.d.ts.map +1 -0
- package/dist/paywall/strings.d.ts +10 -0
- package/dist/paywall/strings.d.ts.map +1 -0
- package/dist/paywall/templates.d.ts +14 -0
- package/dist/paywall/templates.d.ts.map +1 -0
- package/dist/paywall.d.mts +160 -0
- package/dist/paywall.d.ts +160 -0
- package/dist/paywall.esm.js +442 -0
- package/dist/paywall.esm.js.map +1 -0
- package/dist/paywall.js +462 -0
- package/dist/paywall.js.map +1 -0
- package/dist/paywall.mjs +442 -0
- package/dist/paywall.mjs.map +1 -0
- package/dist/types/config.d.ts +62 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/contract.d.ts +172 -0
- package/dist/types/contract.d.ts.map +1 -0
- package/dist/types/entitlement.d.ts +71 -0
- package/dist/types/entitlement.d.ts.map +1 -0
- package/dist/types/errors.d.ts +31 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/events.d.ts +29 -0
- package/dist/types/events.d.ts.map +1 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/paywall.d.ts +37 -0
- package/dist/types/paywall.d.ts.map +1 -0
- package/dist/utils/logger.d.ts +16 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/version.d.ts +3 -0
- package/dist/version.d.ts.map +1 -0
- package/package.json +115 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hosted checkout flow.
|
|
3
|
+
*
|
|
4
|
+
* `pay.createCheckout` returns a URL on the seller's provider; the SDK opens
|
|
5
|
+
* it in a new tab (`chrome.tabs.create`, falling back to `window.open`) and
|
|
6
|
+
* polls `pay.claimSession` every 2 s for up to 10 min — and immediately when
|
|
7
|
+
* the extension regains focus — until the webhook has landed. A pending
|
|
8
|
+
* session is persisted so a restarted service worker / reopened popup can
|
|
9
|
+
* finish the claim on the next `initialize()`.
|
|
10
|
+
*/
|
|
11
|
+
import type { PayApi } from '../api/pay-api.js';
|
|
12
|
+
import type { StorageAdapter } from '../core/storage.js';
|
|
13
|
+
import type { SignedEntitlement } from '../types/contract.js';
|
|
14
|
+
import type { CheckoutOptions, CheckoutResult, Entitlement } from '../types/entitlement.js';
|
|
15
|
+
import type { ExtenshiPayEvents } from '../types/events.js';
|
|
16
|
+
export declare const CHECKOUT_POLL_INTERVAL_MS = 2000;
|
|
17
|
+
export declare const CHECKOUT_TIMEOUT_MS: number;
|
|
18
|
+
type OpenUrl = (url: string) => void | Promise<void>;
|
|
19
|
+
type Emit = <K extends keyof ExtenshiPayEvents>(event: K, payload: ExtenshiPayEvents[K]) => void;
|
|
20
|
+
export interface CheckoutManagerOptions {
|
|
21
|
+
api: PayApi;
|
|
22
|
+
storage: StorageAdapter;
|
|
23
|
+
publishableKey: string;
|
|
24
|
+
locale: string | null;
|
|
25
|
+
getEndUserRef: () => Promise<string>;
|
|
26
|
+
/** Verifies + stores the envelope from a completed session. */
|
|
27
|
+
onComplete: (envelope: SignedEntitlement) => Promise<Entitlement>;
|
|
28
|
+
emit: Emit;
|
|
29
|
+
openUrl?: OpenUrl;
|
|
30
|
+
now?: () => number;
|
|
31
|
+
}
|
|
32
|
+
export declare function openInNewTab(url: string): Promise<void>;
|
|
33
|
+
export declare class CheckoutManager {
|
|
34
|
+
private readonly options;
|
|
35
|
+
private active;
|
|
36
|
+
private readonly now;
|
|
37
|
+
constructor(options: CheckoutManagerOptions);
|
|
38
|
+
get pendingKey(): string;
|
|
39
|
+
isActive(): boolean;
|
|
40
|
+
open(sku: string, options?: CheckoutOptions): Promise<CheckoutResult>;
|
|
41
|
+
/** Finishes a checkout that was started before a restart; null when there is nothing to resume. */
|
|
42
|
+
resumePending(): Promise<CheckoutResult | null>;
|
|
43
|
+
private poll;
|
|
44
|
+
private settle;
|
|
45
|
+
}
|
|
46
|
+
export {};
|
|
47
|
+
//# sourceMappingURL=checkout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkout.d.ts","sourceRoot":"","sources":["../../src/payment/checkout.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB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AEvB;IAED,QAAQ,IAAI,OAAO;IAIb,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB,GAAG,OAAO,CAAC,cAAc,CAAC;IAsB/E,mGAAmG;IAC7F,aAAa,IAAI,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;YAmBvC,IAAI;YA8CJ,MAAM;CA0BpB"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Entitlement cache + refresh.
|
|
3
|
+
*
|
|
4
|
+
* The cached envelope is a cache OF the server projection, never a second
|
|
5
|
+
* source of truth: it is verified when stored and re-verified on load (once
|
|
6
|
+
* the project's public key is known), served without a round-trip while the
|
|
7
|
+
* TTL holds, served for up to 48 hours after signed issuance when the network is down, and expired
|
|
8
|
+
* locally by `expiresAt`. Background refresh polls at most every 15 minutes
|
|
9
|
+
* and backs off exponentially on errors.
|
|
10
|
+
*/
|
|
11
|
+
import type { PayApi } from '../api/pay-api.js';
|
|
12
|
+
import type { StorageAdapter } from '../core/storage.js';
|
|
13
|
+
import { type SignedEntitlement } from '../types/contract.js';
|
|
14
|
+
import type { Entitlement, EntitlementSource } from '../types/entitlement.js';
|
|
15
|
+
import { ExtenshiPayError } from '../types/errors.js';
|
|
16
|
+
export declare const MIN_REFRESH_INTERVAL_MS: number;
|
|
17
|
+
export declare const MAX_REFRESH_BACKOFF_MS: number;
|
|
18
|
+
export declare const MAX_OFFLINE_AGE_MS: number;
|
|
19
|
+
export declare const MAX_CLOCK_SKEW_MS: number;
|
|
20
|
+
export interface EntitlementManagerOptions {
|
|
21
|
+
api: PayApi;
|
|
22
|
+
storage: StorageAdapter;
|
|
23
|
+
publishableKey: string;
|
|
24
|
+
cacheTtlMs: number;
|
|
25
|
+
source?: EntitlementSource;
|
|
26
|
+
getEndUserRef: () => Promise<string>;
|
|
27
|
+
/** Base64 raw Ed25519 public key from `getOffer`, or null when unknown/unsigned. */
|
|
28
|
+
getPublicKey: () => Promise<string | null>;
|
|
29
|
+
onChange?: (entitlement: Entitlement) => void;
|
|
30
|
+
onError?: (error: ExtenshiPayError) => void;
|
|
31
|
+
now?: () => number;
|
|
32
|
+
}
|
|
33
|
+
export declare class EntitlementManager {
|
|
34
|
+
private readonly options;
|
|
35
|
+
private held;
|
|
36
|
+
private inflight;
|
|
37
|
+
private timer;
|
|
38
|
+
private refreshGeneration;
|
|
39
|
+
private deadlineTimer;
|
|
40
|
+
private refreshIntervalMs;
|
|
41
|
+
private backoffMs;
|
|
42
|
+
private autoRefresh;
|
|
43
|
+
private readonly online;
|
|
44
|
+
private lastFingerprint;
|
|
45
|
+
private readonly now;
|
|
46
|
+
private readonly source;
|
|
47
|
+
constructor(options: EntitlementManagerOptions);
|
|
48
|
+
get storageKey(): string;
|
|
49
|
+
/** Loads the persisted envelope (unverified until `reverify()`); no network. */
|
|
50
|
+
load(): Promise<Entitlement | null>;
|
|
51
|
+
/** Re-checks the loaded envelope against the project's key; discards it when the signature is invalid. */
|
|
52
|
+
reverify(): Promise<void>;
|
|
53
|
+
getCached(): Entitlement | null;
|
|
54
|
+
isFresh(): boolean;
|
|
55
|
+
get(options?: {
|
|
56
|
+
force?: boolean;
|
|
57
|
+
}): Promise<Entitlement>;
|
|
58
|
+
/** Fetches the projection from the backend, verifies and stores it. */
|
|
59
|
+
refresh(): Promise<Entitlement>;
|
|
60
|
+
/** Verifies and stores an envelope obtained elsewhere (e.g. from `claimSession`). */
|
|
61
|
+
accept(envelope: SignedEntitlement, source?: EntitlementSource): Promise<Entitlement>;
|
|
62
|
+
/** Drain an older installation refresh before changing identity. */
|
|
63
|
+
settleRefresh(): Promise<void>;
|
|
64
|
+
clear(): Promise<void>;
|
|
65
|
+
startAutoRefresh(intervalMs?: number): void;
|
|
66
|
+
stopAutoRefresh(): void;
|
|
67
|
+
private scheduleDeadline;
|
|
68
|
+
private schedule;
|
|
69
|
+
private safePublicKey;
|
|
70
|
+
private discard;
|
|
71
|
+
private fingerprint;
|
|
72
|
+
private notifyIfChanged;
|
|
73
|
+
private offlineDeadline;
|
|
74
|
+
private snapshot;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=entitlement.d.ts.map
|
|
@@ -0,0 +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,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAC7E,OAAO,EAAe,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAKlE,eAAO,MAAM,uBAAuB,QAAiB,CAAA;AACrD,eAAO,MAAM,sBAAsB,QAAqB,CAAA;AACxD,eAAO,MAAM,kBAAkB,QAAsB,CAAA;AAErD,eAAO,MAAM,iBAAiB,QAAgB,CAAA;AAgB9C,MAAM,WAAW,yBAAyB;IACzC,GAAG,EAAE,MAAM,CAAA;IACX,OAAO,EAAE,cAAc,CAAA;IACvB,cAAc,EAAE,MAAM,CAAA;IACtB,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE,iBAAiB,CAAA;IAC1B,aAAa,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAA;IACpC,oFAAoF;IACpF,YAAY,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAA;IAC1C,QAAQ,CAAC,EAAE,CAAC,WAAW,EAAE,WAAW,KAAK,IAAI,CAAA;IAC7C,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,CAAA;IAC3C,GAAG,CAAC,EAAE,MAAM,MAAM,CAAA;CAClB;AAcD,qBAAa,kBAAkB;IA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F,aAAa;YASb,OAAO;IAOrB,OAAO,CAAC,WAAW;IAKnB,OAAO,CAAC,eAAe;IAOvB,OAAO,CAAC,eAAe;IAMvB,OAAO,CAAC,QAAQ;CA8BhB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Pure helpers over the entitlement projection. Features come from the items' `features[]`. */
|
|
2
|
+
import type { PayEntitlementItem } from '../types/contract.js';
|
|
3
|
+
import type { Entitlement } from '../types/entitlement.js';
|
|
4
|
+
export declare function isLive(item: PayEntitlementItem): boolean;
|
|
5
|
+
/** An item past its `expiresAt` reads as expired without a network round-trip. */
|
|
6
|
+
export declare function applyLocalExpiry(items: PayEntitlementItem[], now?: number): PayEntitlementItem[];
|
|
7
|
+
export declare function collectFeatures(items: PayEntitlementItem[]): string[];
|
|
8
|
+
export declare function isEntitled(entitlement: Entitlement, sku?: string): boolean;
|
|
9
|
+
export declare function hasFeature(entitlement: Entitlement, feature: string): boolean;
|
|
10
|
+
export declare function checkFeatures(entitlement: Entitlement, features: string[]): Record<string, boolean>;
|
|
11
|
+
export declare const EMPTY_ENTITLEMENT: Entitlement;
|
|
12
|
+
//# sourceMappingURL=features.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features.d.ts","sourceRoot":"","sources":["../../src/payment/features.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAEhG,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAI1D,wBAAgB,MAAM,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAExD;AAED,kFAAkF;AAClF,wBAAgB,gBAAgB,CAC/B,KAAK,EAAE,kBAAkB,EAAE,EAC3B,GAAG,GAAE,MAAmB,GACtB,kBAAkB,EAAE,CAMtB;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,kBAAkB,EAAE,GAAG,MAAM,EAAE,CAOrE;AAED,wBAAgB,UAAU,CAAC,WAAW,EAAE,WAAW,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAK1E;AAED,wBAAgB,UAAU,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAE7E;AAED,wBAAgB,aAAa,CAAC,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAInG;AAED,eAAO,MAAM,iBAAiB,EAAE,WASf,CAAA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** Email stays on the hosted page. Only this extension context holds the claim secret. */
|
|
2
|
+
import type { PayApi } from '../api/pay-api.js';
|
|
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';
|
|
6
|
+
/** storage.local is exposed to content scripts by default. Never put a recovery proof there. */
|
|
7
|
+
export declare function createRecoveryStorage(): StorageAdapter;
|
|
8
|
+
export interface RecoveryManagerOptions {
|
|
9
|
+
api: PayApi;
|
|
10
|
+
storage: StorageAdapter;
|
|
11
|
+
publishableKey: string;
|
|
12
|
+
onComplete: (endUserRef: string, envelope: SignedEntitlement) => Promise<Entitlement>;
|
|
13
|
+
openUrl?: (url: string) => void | Promise<void>;
|
|
14
|
+
now?: () => number;
|
|
15
|
+
}
|
|
16
|
+
export declare class RecoveryManager {
|
|
17
|
+
private readonly options;
|
|
18
|
+
private active;
|
|
19
|
+
private stopped;
|
|
20
|
+
private wake;
|
|
21
|
+
constructor(options: RecoveryManagerOptions);
|
|
22
|
+
get pendingKey(): string;
|
|
23
|
+
isActive(): boolean;
|
|
24
|
+
stop(): void;
|
|
25
|
+
open(options?: RestoreOptions): Promise<RestoreResult>;
|
|
26
|
+
resumePending(): Promise<RestoreResult | null>;
|
|
27
|
+
private poll;
|
|
28
|
+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YAsBtC,IAAI;CAiDlB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ed25519 verification of the entitlement projection.
|
|
3
|
+
*
|
|
4
|
+
* Tamper resistance, not DRM. Trust comes from the developer's bundled key or
|
|
5
|
+
* a key fetched over HTTPS, never from editable extension storage. Callers must
|
|
6
|
+
* deny access for both invalid and unverified envelopes outside explicit mocks.
|
|
7
|
+
*/
|
|
8
|
+
import { type SignedEntitlement } from '../types/contract.js';
|
|
9
|
+
export type SignatureVerdict = 'valid' | 'invalid' | 'unverified';
|
|
10
|
+
export declare function base64ToBytes(base64: string): Uint8Array<ArrayBuffer>;
|
|
11
|
+
export declare function verifyEntitlementSignature(envelope: SignedEntitlement, publicKeyBase64: string | null): Promise<SignatureVerdict>;
|
|
12
|
+
//# sourceMappingURL=signature.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signature.d.ts","sourceRoot":"","sources":["../../src/payment/signature.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAiB,KAAK,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAE5E,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,SAAS,GAAG,YAAY,CAAA;AAEjE,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAAC,WAAW,CAAC,CAKrE;AAED,wBAAsB,0BAA0B,CAC/C,QAAQ,EAAE,iBAAiB,EAC3B,eAAe,EAAE,MAAM,GAAG,IAAI,GAC5B,OAAO,CAAC,gBAAgB,CAAC,CAsB3B"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { PayPortalAccount } from '../types/contract.js';
|
|
2
|
+
/** Bundled UI only. Native dialog provides modal focus containment and Escape. */
|
|
3
|
+
export declare class BillingProfilePicker {
|
|
4
|
+
private dismiss;
|
|
5
|
+
hide(): void;
|
|
6
|
+
show(accounts: PayPortalAccount[]): Promise<string | null>;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=billing-profile-picker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"billing-profile-picker.d.ts","sourceRoot":"","sources":["../../src/paywall/billing-profile-picker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAG5D,kFAAkF;AAClF,qBAAa,oBAAoB;IAChC,OAAO,CAAC,OAAO,CAA4B;IAE3C,IAAI,IAAI,IAAI;IAIZ,IAAI,CAAC,QAAQ,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;CAsF1D"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { PayOfferDto } from '../types/contract.js';
|
|
2
|
+
import type { PaywallStrings } from '../types/paywall.js';
|
|
3
|
+
export interface FormattedPrice {
|
|
4
|
+
/** Currency symbol/code as the locale renders it (`$`, `€`, `US$`). */
|
|
5
|
+
currency: string;
|
|
6
|
+
/** Numeric part (`9.99`, `9,99`). */
|
|
7
|
+
amount: string;
|
|
8
|
+
/** The whole formatted price (`$9.99`). */
|
|
9
|
+
full: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function formatPrice(amountMinor: number, currency: string, locale?: string | null): FormattedPrice;
|
|
12
|
+
export declare function periodLabel(offer: PayOfferDto, strings: PaywallStrings): string;
|
|
13
|
+
//# sourceMappingURL=format.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/paywall/format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAEzD,MAAM,WAAW,cAAc;IAC9B,uEAAuE;IACvE,QAAQ,EAAE,MAAM,CAAA;IAChB,qCAAqC;IACrC,MAAM,EAAE,MAAM,CAAA;IACd,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAA;CACZ;AAED,wBAAgB,WAAW,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,cAAc,CAqBzG;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,cAAc,GAAG,MAAM,CAG/E"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type { PaywallMode, PaywallOptions, PaywallStrings, ThemeConfig } from '../types/index.js';
|
|
2
|
+
export type { FormattedPrice } from './format.js';
|
|
3
|
+
export { formatPrice, periodLabel } from './format.js';
|
|
4
|
+
export type { PaywallRendererCallbacks, PaywallView } from './renderer.js';
|
|
5
|
+
export { buildContent, escapeHtml, PAYWALL_HOST_CLASS, PaywallRenderer, resolveThemeMode, substitute, themeCss, } from './renderer.js';
|
|
6
|
+
export { DEFAULT_STRINGS } from './strings.js';
|
|
7
|
+
export type { PaywallTemplate } from './templates.js';
|
|
8
|
+
export { PAYWALL_MODES, PAYWALL_SHARED_CSS, PAYWALL_TEMPLATES } from './templates.js';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/paywall/index.ts"],"names":[],"mappings":"AAEA,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACjG,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACtD,YAAY,EAAE,wBAAwB,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC1E,OAAO,EACN,YAAY,EACZ,UAAU,EACV,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,UAAU,EACV,QAAQ,GACR,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { LicenseSummary } from '../types/entitlement.js';
|
|
2
|
+
export declare class LicensePanel {
|
|
3
|
+
private dismiss;
|
|
4
|
+
hide(): void;
|
|
5
|
+
show(summary: LicenseSummary, actions: {
|
|
6
|
+
restore: () => Promise<LicenseSummary>;
|
|
7
|
+
manage: () => Promise<string | null>;
|
|
8
|
+
}): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=license-panel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"license-panel.d.ts","sourceRoot":"","sources":["../../src/paywall/license-panel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAK7D,qBAAa,YAAY;IACxB,OAAO,CAAC,OAAO,CAA4B;IAC3C,IAAI,IAAI,IAAI;IAGZ,IAAI,CACH,OAAO,EAAE,cAAc,EACvB,OAAO,EAAE;QACR,OAAO,EAAE,MAAM,OAAO,CAAC,cAAc,CAAC,CAAA;QACtC,MAAM,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAA;KACpC,GACC,OAAO,CAAC,IAAI,CAAC;CAiJhB"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one paywall renderer.
|
|
3
|
+
*
|
|
4
|
+
* Renders a template from `@extenshi/paywall-templates` into a Shadow DOM
|
|
5
|
+
* host so the templates' resets never leak into the extension page (and vice
|
|
6
|
+
* versa). Placeholders (`{{title}}`, `{{price}}` …) are filled from the offer
|
|
7
|
+
* and the strings dictionary, every value HTML-escaped; buttons are bound with
|
|
8
|
+
* `addEventListener` on `data-ep-action` (no inline handlers, no scripts).
|
|
9
|
+
*/
|
|
10
|
+
import type { ThemeConfig } from '../types/config.js';
|
|
11
|
+
import type { PayOfferDto, PaySellerPublic } from '../types/contract.js';
|
|
12
|
+
import type { PaywallMode, PaywallStrings } from '../types/paywall.js';
|
|
13
|
+
export interface PaywallView {
|
|
14
|
+
mode: PaywallMode;
|
|
15
|
+
title: string;
|
|
16
|
+
description: string;
|
|
17
|
+
features: string[];
|
|
18
|
+
freeFeatures: string[];
|
|
19
|
+
brandName: string;
|
|
20
|
+
offer: PayOfferDto | null;
|
|
21
|
+
checkoutEnabled: boolean;
|
|
22
|
+
mock?: boolean;
|
|
23
|
+
recoveryEnabled?: boolean;
|
|
24
|
+
seller?: PaySellerPublic | null;
|
|
25
|
+
locale: string | null;
|
|
26
|
+
theme: ThemeConfig;
|
|
27
|
+
strings: Partial<PaywallStrings>;
|
|
28
|
+
container?: HTMLElement;
|
|
29
|
+
}
|
|
30
|
+
export interface PaywallRendererCallbacks {
|
|
31
|
+
onUpgrade: (sku: string) => void;
|
|
32
|
+
onClose: () => void;
|
|
33
|
+
onRestore?: () => void;
|
|
34
|
+
}
|
|
35
|
+
export declare const PAYWALL_HOST_CLASS = "extenshi-paywall-host";
|
|
36
|
+
export declare function escapeHtml(value: string): string;
|
|
37
|
+
export declare function substitute(html: string, content: Record<string, string>): string;
|
|
38
|
+
export declare function buildContent(view: PaywallView, strings: PaywallStrings): Record<string, string>;
|
|
39
|
+
export declare function themeCss(theme: ThemeConfig): string;
|
|
40
|
+
export declare function resolveThemeMode(theme: ThemeConfig): 'light' | 'dark';
|
|
41
|
+
export declare class PaywallRenderer {
|
|
42
|
+
private readonly callbacks;
|
|
43
|
+
private host;
|
|
44
|
+
private keyHandler;
|
|
45
|
+
constructor(callbacks: PaywallRendererCallbacks);
|
|
46
|
+
isVisible(): boolean;
|
|
47
|
+
/** Returns the host element; its shadow root holds the rendered template. */
|
|
48
|
+
show(view: PaywallView): HTMLElement;
|
|
49
|
+
hide(): void;
|
|
50
|
+
private prune;
|
|
51
|
+
private bind;
|
|
52
|
+
private reveal;
|
|
53
|
+
private close;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=renderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../src/paywall/renderer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAExE,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAMtE,MAAM,WAAW,WAAW;IAC3B,IAAI,EAAE,WAAW,CAAA;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,YAAY,EAAE,MAAM,EAAE,CAAA;IACtB,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,WAAW,GAAG,IAAI,CAAA;IACzB,eAAe,EAAE,OAAO,CAAA;IACxB,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,MAAM,CAAC,EAAE,eAAe,GAAG,IAAI,CAAA;IAC/B,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,KAAK,EAAE,WAAW,CAAA;IAClB,OAAO,EAAE,OAAO,CAAC,cAAc,CAAC,CAAA;IAChC,SAAS,CAAC,EAAE,WAAW,CAAA;CACvB;AAED,MAAM,WAAW,wBAAwB;IACxC,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;IAChC,OAAO,EAAE,MAAM,IAAI,CAAA;IACnB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAA;CACtB;AAED,eAAO,MAAM,kBAAkB,0BAA0B,CAAA;AAmDzD,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAOhD;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAMhF;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA8B/F;AAID,wBAAgB,QAAQ,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAcnD;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,GAAG,MAAM,CAQrE;AAED,qBAAa,eAAe;IAIf,OAAO,CAAC,QAAQ,CAAC,SAAS;IAHtC,OAAO,CAAC,IAAI,CAA2B;IACvC,OAAO,CAAC,UAAU,CAAgD;gBAErC,SAAS,EAAE,wBAAwB;IAEhE,SAAS,IAAI,OAAO;IAIpB,6EAA6E;IAC7E,IAAI,CAAC,IAAI,EAAE,WAAW,GAAG,WAAW;IAyEpC,IAAI,IAAI,IAAI;IAUZ,OAAO,CAAC,KAAK;IAcb,OAAO,CAAC,IAAI;IAqCZ,OAAO,CAAC,MAAM;IAUd,OAAO,CAAC,KAAK;CAIb"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { PaySellerPublic } from '../types/contract.js';
|
|
2
|
+
/** Treat even server-provided links as untrusted; never render executable protocols. */
|
|
3
|
+
export declare function publicContactUrl(value: string): string | null;
|
|
4
|
+
export declare function sellerDetails(seller: PaySellerPublic | null): HTMLElement;
|
|
5
|
+
//# sourceMappingURL=seller-details.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"seller-details.d.ts","sourceRoot":"","sources":["../../src/paywall/seller-details.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAE3D,wFAAwF;AACxF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAS7D;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI,GAAG,WAAW,CA4BzE"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every string the SDK adds on top of the templates. English only for now;
|
|
3
|
+
* iteration 12 T9 / 13 replaces this dictionary per locale. Do not add
|
|
4
|
+
* promotional claims here without marketing/legal review (see
|
|
5
|
+
* .claude/modules/paywall-templates.md).
|
|
6
|
+
*/
|
|
7
|
+
import type { PaywallStrings } from '../types/paywall.js';
|
|
8
|
+
export declare const MOCK_PAYMENT_NOTICE = "Development preview: licenses and payments are simulated. No payment will be taken.";
|
|
9
|
+
export declare const DEFAULT_STRINGS: PaywallStrings;
|
|
10
|
+
//# sourceMappingURL=strings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strings.d.ts","sourceRoot":"","sources":["../../src/paywall/strings.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAEzD,eAAO,MAAM,mBAAmB,wFACsD,CAAA;AAEtF,eAAO,MAAM,eAAe,EAAE,cAc7B,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The five templates from `@extenshi/paywall-templates`, inlined at build
|
|
3
|
+
* time by build/paywall-templates-plugin.mjs. No runtime fetch, no
|
|
4
|
+
* `web_accessible_resources`, no remote code.
|
|
5
|
+
*/
|
|
6
|
+
import type { PaywallMode } from '../types/paywall.js';
|
|
7
|
+
export interface PaywallTemplate {
|
|
8
|
+
html: string;
|
|
9
|
+
css: string;
|
|
10
|
+
}
|
|
11
|
+
export declare const PAYWALL_SHARED_CSS: string;
|
|
12
|
+
export declare const PAYWALL_TEMPLATES: Record<PaywallMode, PaywallTemplate>;
|
|
13
|
+
export declare const PAYWALL_MODES: PaywallMode[];
|
|
14
|
+
//# sourceMappingURL=templates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/paywall/templates.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAEtD,MAAM,WAAW,eAAe;IAC/B,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;CACX;AAED,eAAO,MAAM,kBAAkB,EAAE,MAAkB,CAAA;AAEnD,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,WAAW,EAAE,eAAe,CAMlE,CAAA;AAED,eAAO,MAAM,aAAa,EAAqC,WAAW,EAAE,CAAA"}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
declare const PAY_OFFER_KINDS: readonly ["one_time", "subscription", "lifetime"];
|
|
2
|
+
type PayOfferKind = (typeof PAY_OFFER_KINDS)[number];
|
|
3
|
+
declare const PAY_OFFER_INTERVALS: readonly ["month", "year"];
|
|
4
|
+
type PayOfferInterval = (typeof PAY_OFFER_INTERVALS)[number];
|
|
5
|
+
/** ISO-4217 lowercase, matching what every gateway returns. */
|
|
6
|
+
declare const PAY_CURRENCIES: readonly ["usd", "eur", "gbp"];
|
|
7
|
+
type PayCurrency = (typeof PAY_CURRENCIES)[number];
|
|
8
|
+
interface PayOfferDto {
|
|
9
|
+
sku: string;
|
|
10
|
+
kind: PayOfferKind;
|
|
11
|
+
interval: PayOfferInterval | null;
|
|
12
|
+
amountMinor: number;
|
|
13
|
+
currency: PayCurrency;
|
|
14
|
+
title: string;
|
|
15
|
+
description: string | null;
|
|
16
|
+
features: string[];
|
|
17
|
+
}
|
|
18
|
+
/** Public author-provided contact details. Not a claim of identity verification. */
|
|
19
|
+
interface PaySellerPublic {
|
|
20
|
+
displayName: string;
|
|
21
|
+
/** HTTPS support page or plain email address. */
|
|
22
|
+
supportUrl: string;
|
|
23
|
+
termsUrl: string | null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
interface ThemeConfig {
|
|
27
|
+
/** `auto` follows `prefers-color-scheme`. */
|
|
28
|
+
mode?: 'light' | 'dark' | 'auto';
|
|
29
|
+
primaryColor?: string;
|
|
30
|
+
fontFamily?: string;
|
|
31
|
+
borderRadius?: string;
|
|
32
|
+
/** Appended verbatim inside the paywall's shadow root. */
|
|
33
|
+
customCss?: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
type PaywallMode = 'modal' | 'inline' | 'sidebar' | 'fullscreen' | 'minimal';
|
|
37
|
+
/** Every user-visible string the SDK adds on top of the templates (English only; iteration 12 T9 swaps locales). */
|
|
38
|
+
interface PaywallStrings {
|
|
39
|
+
title: string;
|
|
40
|
+
description: string;
|
|
41
|
+
upgrade: string;
|
|
42
|
+
cancel: string;
|
|
43
|
+
dismiss: string;
|
|
44
|
+
remindLater: string;
|
|
45
|
+
continueFree: string;
|
|
46
|
+
checkoutUnavailable: string;
|
|
47
|
+
periodMonth: string;
|
|
48
|
+
periodYear: string;
|
|
49
|
+
periodOnce: string;
|
|
50
|
+
footer: string;
|
|
51
|
+
restorePurchase: string;
|
|
52
|
+
}
|
|
53
|
+
interface PaywallOptions {
|
|
54
|
+
/** Template to render (default `modal`). */
|
|
55
|
+
mode?: PaywallMode;
|
|
56
|
+
/** Offer to feature; defaults to the first active offer. */
|
|
57
|
+
sku?: string;
|
|
58
|
+
title?: string;
|
|
59
|
+
description?: string;
|
|
60
|
+
/** Overrides the offer's `features[]`. */
|
|
61
|
+
features?: string[];
|
|
62
|
+
/** Free-tier bullets for the comparison templates (`inline`, `fullscreen`). */
|
|
63
|
+
freeFeatures?: string[];
|
|
64
|
+
theme?: ThemeConfig;
|
|
65
|
+
/** Mount point for `inline` mode (default `document.body`). */
|
|
66
|
+
container?: HTMLElement;
|
|
67
|
+
strings?: Partial<PaywallStrings>;
|
|
68
|
+
onUpgrade?: (sku: string) => void;
|
|
69
|
+
onClose?: () => void;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
interface FormattedPrice {
|
|
73
|
+
/** Currency symbol/code as the locale renders it (`$`, `€`, `US$`). */
|
|
74
|
+
currency: string;
|
|
75
|
+
/** Numeric part (`9.99`, `9,99`). */
|
|
76
|
+
amount: string;
|
|
77
|
+
/** The whole formatted price (`$9.99`). */
|
|
78
|
+
full: string;
|
|
79
|
+
}
|
|
80
|
+
declare function formatPrice(amountMinor: number, currency: string, locale?: string | null): FormattedPrice;
|
|
81
|
+
declare function periodLabel(offer: PayOfferDto, strings: PaywallStrings): string;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* The one paywall renderer.
|
|
85
|
+
*
|
|
86
|
+
* Renders a template from `@extenshi/paywall-templates` into a Shadow DOM
|
|
87
|
+
* host so the templates' resets never leak into the extension page (and vice
|
|
88
|
+
* versa). Placeholders (`{{title}}`, `{{price}}` …) are filled from the offer
|
|
89
|
+
* and the strings dictionary, every value HTML-escaped; buttons are bound with
|
|
90
|
+
* `addEventListener` on `data-ep-action` (no inline handlers, no scripts).
|
|
91
|
+
*/
|
|
92
|
+
|
|
93
|
+
interface PaywallView {
|
|
94
|
+
mode: PaywallMode;
|
|
95
|
+
title: string;
|
|
96
|
+
description: string;
|
|
97
|
+
features: string[];
|
|
98
|
+
freeFeatures: string[];
|
|
99
|
+
brandName: string;
|
|
100
|
+
offer: PayOfferDto | null;
|
|
101
|
+
checkoutEnabled: boolean;
|
|
102
|
+
mock?: boolean;
|
|
103
|
+
recoveryEnabled?: boolean;
|
|
104
|
+
seller?: PaySellerPublic | null;
|
|
105
|
+
locale: string | null;
|
|
106
|
+
theme: ThemeConfig;
|
|
107
|
+
strings: Partial<PaywallStrings>;
|
|
108
|
+
container?: HTMLElement;
|
|
109
|
+
}
|
|
110
|
+
interface PaywallRendererCallbacks {
|
|
111
|
+
onUpgrade: (sku: string) => void;
|
|
112
|
+
onClose: () => void;
|
|
113
|
+
onRestore?: () => void;
|
|
114
|
+
}
|
|
115
|
+
declare const PAYWALL_HOST_CLASS = "extenshi-paywall-host";
|
|
116
|
+
declare function escapeHtml(value: string): string;
|
|
117
|
+
declare function substitute(html: string, content: Record<string, string>): string;
|
|
118
|
+
declare function buildContent(view: PaywallView, strings: PaywallStrings): Record<string, string>;
|
|
119
|
+
declare function themeCss(theme: ThemeConfig): string;
|
|
120
|
+
declare function resolveThemeMode(theme: ThemeConfig): 'light' | 'dark';
|
|
121
|
+
declare class PaywallRenderer {
|
|
122
|
+
private readonly callbacks;
|
|
123
|
+
private host;
|
|
124
|
+
private keyHandler;
|
|
125
|
+
constructor(callbacks: PaywallRendererCallbacks);
|
|
126
|
+
isVisible(): boolean;
|
|
127
|
+
/** Returns the host element; its shadow root holds the rendered template. */
|
|
128
|
+
show(view: PaywallView): HTMLElement;
|
|
129
|
+
hide(): void;
|
|
130
|
+
private prune;
|
|
131
|
+
private bind;
|
|
132
|
+
private reveal;
|
|
133
|
+
private close;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Every string the SDK adds on top of the templates. English only for now;
|
|
138
|
+
* iteration 12 T9 / 13 replaces this dictionary per locale. Do not add
|
|
139
|
+
* promotional claims here without marketing/legal review (see
|
|
140
|
+
* .claude/modules/paywall-templates.md).
|
|
141
|
+
*/
|
|
142
|
+
|
|
143
|
+
declare const DEFAULT_STRINGS: PaywallStrings;
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* The five templates from `@extenshi/paywall-templates`, inlined at build
|
|
147
|
+
* time by build/paywall-templates-plugin.mjs. No runtime fetch, no
|
|
148
|
+
* `web_accessible_resources`, no remote code.
|
|
149
|
+
*/
|
|
150
|
+
|
|
151
|
+
interface PaywallTemplate {
|
|
152
|
+
html: string;
|
|
153
|
+
css: string;
|
|
154
|
+
}
|
|
155
|
+
declare const PAYWALL_SHARED_CSS: string;
|
|
156
|
+
declare const PAYWALL_TEMPLATES: Record<PaywallMode, PaywallTemplate>;
|
|
157
|
+
declare const PAYWALL_MODES: PaywallMode[];
|
|
158
|
+
|
|
159
|
+
export { DEFAULT_STRINGS, PAYWALL_HOST_CLASS, PAYWALL_MODES, PAYWALL_SHARED_CSS, PAYWALL_TEMPLATES, PaywallRenderer, buildContent, escapeHtml, formatPrice, periodLabel, resolveThemeMode, substitute, themeCss };
|
|
160
|
+
export type { FormattedPrice, PaywallMode, PaywallOptions, PaywallRendererCallbacks, PaywallStrings, PaywallTemplate, PaywallView, ThemeConfig };
|