@zerocost/sdk 0.11.0 → 0.13.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.
@@ -0,0 +1,27 @@
1
+ /**
2
+ * consent-ui.ts — Pure DOM consent popup for the Zerocost SDK.
3
+ *
4
+ * - Desktop: centered card modal (max 480px)
5
+ * - Mobile (≤640px): bottom-sheet modal
6
+ * - Themes: light / dark / auto
7
+ * - Non-dismissable (no Escape, no backdrop click)
8
+ * - Returns a Promise that resolves with the user's toggle selections
9
+ */
10
+ export interface ConsentUIOptions {
11
+ appName: string;
12
+ theme: 'light' | 'dark' | 'auto';
13
+ privacyPolicyUrl?: string;
14
+ defaults?: {
15
+ ads: boolean;
16
+ usageData: boolean;
17
+ aiInteractions: boolean;
18
+ };
19
+ }
20
+ export interface ConsentUIResult {
21
+ ads: boolean;
22
+ usageData: boolean;
23
+ aiInteractions: boolean;
24
+ }
25
+ export declare function showConsentUI(options: ConsentUIOptions): Promise<ConsentUIResult>;
26
+ /** Remove any existing consent popup from the DOM */
27
+ export declare function removeConsentUI(): void;
@@ -1,7 +1,37 @@
1
- import { UserConsent } from '../types';
1
+ import { ZerocostClient } from './client';
2
+ import { ZerocostConsentRecord, ConsentFeature, ConsentConfig } from '../types';
2
3
  export declare class ConsentManager {
3
- private consent;
4
- updateConsent(newConsent: Partial<UserConsent>): void;
5
- hasAnalyticsConsent(): boolean;
6
- hasAdvertisingConsent(): boolean;
4
+ private record;
5
+ private needsReset;
6
+ private client;
7
+ private consentConfig;
8
+ private appName;
9
+ private theme;
10
+ constructor(client: ZerocostClient, opts: {
11
+ appName?: string;
12
+ theme?: 'light' | 'dark' | 'auto';
13
+ consent?: ConsentConfig;
14
+ });
15
+ /** Returns the current consent record, or null if none exists. */
16
+ get(): ZerocostConsentRecord | null;
17
+ /** Programmatically open the consent popup (e.g. from app settings). */
18
+ open(): Promise<void>;
19
+ /** Clear consent — prompt will re-fire on next init(). */
20
+ reset(): void;
21
+ /** Restore a previously saved record (skip re-prompting if valid). */
22
+ restore(record: ZerocostConsentRecord): void;
23
+ /** Check whether a specific feature is consented. */
24
+ has(feature: ConsentFeature): boolean;
25
+ /** Should the consent prompt be shown? */
26
+ shouldPrompt(): boolean;
27
+ /** Show the consent popup, wait for confirmation, store record. */
28
+ promptAndWait(): Promise<void>;
29
+ private isValid;
30
+ private storageKey;
31
+ private hydrateFromStorage;
32
+ private writeStorage;
33
+ private clearStorage;
34
+ private getOrCreateUserId;
35
+ private generateUUID;
36
+ private submitToServer;
7
37
  }
@@ -0,0 +1,8 @@
1
+ import { AdResponse } from '../types';
2
+ export declare const SDK_WIDGET_REFRESH_MS = 20000;
3
+ interface WidgetRenderOptions {
4
+ format: string;
5
+ theme?: string;
6
+ }
7
+ export declare function renderWidgetMarkup(ad: AdResponse, options: WidgetRenderOptions): string;
8
+ export {};