@peax/consent-core 0.6.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,222 @@
1
+ import * as z from 'zod/mini';
2
+
3
+ /** Disjoint category/use decisions for one scope actually presented to the user. */
4
+ declare type BatchCommand = z.infer<typeof consentDecisionsCommandSchema>;
5
+
6
+ /** Records choices only for category members in userConsentedPolicy, not future members. */
7
+ declare type CategoryConsentCommand = z.infer<typeof categoryConsentCommandSchema>;
8
+
9
+ declare const categoryConsentCommandSchema: z.ZodMiniReadonly<z.ZodMiniObject<{
10
+ userConsentedPolicy: z.ZodMiniReadonly<z.ZodMiniObject<{
11
+ purposes: z.ZodMiniReadonly<z.ZodMiniArray<z.ZodMiniReadonly<z.ZodMiniObject<{
12
+ id: z.ZodMiniString<string>;
13
+ title: z.ZodMiniString<string>;
14
+ description: z.ZodMiniString<string>;
15
+ }, z.core.$strict>>>>;
16
+ uses: z.ZodMiniReadonly<z.ZodMiniArray<z.ZodMiniReadonly<z.ZodMiniObject<{
17
+ id: z.ZodMiniString<string>;
18
+ serviceId: z.ZodMiniString<string>;
19
+ categoryId: z.ZodMiniString<string>;
20
+ purposeId: z.ZodMiniString<string>;
21
+ consentVersion: z.ZodMiniInt;
22
+ }, z.core.$strict>>>>;
23
+ }, z.core.$strict>>;
24
+ categoryId: z.ZodMiniString<string>;
25
+ decision: z.ZodMiniEnum<{
26
+ granted: "granted";
27
+ denied: "denied";
28
+ }>;
29
+ }, z.core.$strict>>;
30
+
31
+ /** userConsentedPolicy is the scope shown for this decision, including a denial. */
32
+ declare type ConsentDecisionCommand = z.infer<typeof consentDecisionCommandSchema>;
33
+
34
+ declare const consentDecisionCommandSchema: z.ZodMiniReadonly<z.ZodMiniObject<{
35
+ userConsentedPolicy: z.ZodMiniReadonly<z.ZodMiniObject<{
36
+ purposes: z.ZodMiniReadonly<z.ZodMiniArray<z.ZodMiniReadonly<z.ZodMiniObject<{
37
+ id: z.ZodMiniString<string>;
38
+ title: z.ZodMiniString<string>;
39
+ description: z.ZodMiniString<string>;
40
+ }, z.core.$strict>>>>;
41
+ uses: z.ZodMiniReadonly<z.ZodMiniArray<z.ZodMiniReadonly<z.ZodMiniObject<{
42
+ id: z.ZodMiniString<string>;
43
+ serviceId: z.ZodMiniString<string>;
44
+ categoryId: z.ZodMiniString<string>;
45
+ purposeId: z.ZodMiniString<string>;
46
+ consentVersion: z.ZodMiniInt;
47
+ }, z.core.$strict>>>>;
48
+ }, z.core.$strict>>;
49
+ useId: z.ZodMiniString<string>;
50
+ decision: z.ZodMiniEnum<{
51
+ granted: "granted";
52
+ denied: "denied";
53
+ }>;
54
+ }, z.core.$strict>>;
55
+
56
+ declare type ConsentDecisionsCommand = Readonly<Omit<BatchCommand, 'decisions'> & {
57
+ decisions: readonly ExclusiveTarget<BatchCommand['decisions'][number]>[];
58
+ }>;
59
+
60
+ declare const consentDecisionsCommandSchema: z.ZodMiniReadonly<z.ZodMiniObject<{
61
+ userConsentedPolicy: z.ZodMiniReadonly<z.ZodMiniObject<{
62
+ purposes: z.ZodMiniReadonly<z.ZodMiniArray<z.ZodMiniReadonly<z.ZodMiniObject<{
63
+ id: z.ZodMiniString<string>;
64
+ title: z.ZodMiniString<string>;
65
+ description: z.ZodMiniString<string>;
66
+ }, z.core.$strict>>>>;
67
+ uses: z.ZodMiniReadonly<z.ZodMiniArray<z.ZodMiniReadonly<z.ZodMiniObject<{
68
+ id: z.ZodMiniString<string>;
69
+ serviceId: z.ZodMiniString<string>;
70
+ categoryId: z.ZodMiniString<string>;
71
+ purposeId: z.ZodMiniString<string>;
72
+ consentVersion: z.ZodMiniInt;
73
+ }, z.core.$strict>>>>;
74
+ }, z.core.$strict>>;
75
+ decisions: z.ZodMiniReadonly<z.ZodMiniArray<z.ZodMiniUnion<readonly [z.ZodMiniReadonly<z.ZodMiniObject<{
76
+ useId: z.ZodMiniString<string>;
77
+ decision: z.ZodMiniEnum<{
78
+ granted: "granted";
79
+ denied: "denied";
80
+ }>;
81
+ }, z.core.$strict>>, z.ZodMiniReadonly<z.ZodMiniObject<{
82
+ categoryId: z.ZodMiniString<string>;
83
+ decision: z.ZodMiniEnum<{
84
+ granted: "granted";
85
+ denied: "denied";
86
+ }>;
87
+ }, z.core.$strict>>]>>>;
88
+ }, z.core.$strict>>;
89
+
90
+ declare type ConsentDeniedReason = 'unknown-use' | 'undecided' | 'denied' | 'consent-version-mismatch';
91
+
92
+ /**
93
+ * Shared shape for enforcement guard errors. Only the concrete classes are public: each subpath
94
+ * exports exactly one of them, so consumers keep their own `instanceof` and literal `name` type.
95
+ */
96
+ declare abstract class ConsentEnforcementError<Reason extends string> extends Error {
97
+ readonly useId: string;
98
+ readonly reason: Reason;
99
+ constructor(message: string, useId: string, reason: Reason);
100
+ }
101
+
102
+ declare type ConsentEvaluation = Readonly<{
103
+ allowed: true;
104
+ }> | Readonly<{
105
+ allowed: false;
106
+ reason: ConsentDeniedReason;
107
+ }>;
108
+
109
+ export declare type ConsentFetch = Readonly<{
110
+ fetch: typeof globalThis.fetch;
111
+ /** Unsubscribes, cancels outstanding fetches/bodies, and permanently closes this guard. */
112
+ dispose: () => void;
113
+ }>;
114
+
115
+ /** Guard rejection or abort reason. Native response-body reads may instead throw AbortError. */
116
+ export declare class ConsentFetchError extends ConsentEnforcementError<ConsentFetchErrorReason> {
117
+ readonly name = "ConsentFetchError";
118
+ constructor(useId: string, reason: ConsentFetchErrorReason);
119
+ }
120
+
121
+ export declare type ConsentFetchErrorReason = ConsentDeniedReason | 'disposed';
122
+
123
+ export declare type ConsentFetchOptions = Readonly<{
124
+ /** An initialized runtime for this user. No state or policy is copied. */
125
+ consent: Pick<ConsentRuntime, 'evaluate' | 'subscribe'>;
126
+ useId: string;
127
+ /** Must honor the supplied AbortSignal like native fetch. */
128
+ fetch?: typeof globalThis.fetch;
129
+ }>;
130
+
131
+ declare type ConsentPolicy = z.infer<typeof consentPolicySchema>;
132
+
133
+ declare const consentPolicySchema: z.ZodMiniReadonly<z.ZodMiniObject<{
134
+ purposes: z.ZodMiniReadonly<z.ZodMiniArray<z.ZodMiniReadonly<z.ZodMiniObject<{
135
+ id: z.ZodMiniString<string>;
136
+ title: z.ZodMiniString<string>;
137
+ description: z.ZodMiniString<string>;
138
+ }, z.core.$strict>>>>;
139
+ uses: z.ZodMiniReadonly<z.ZodMiniArray<z.ZodMiniReadonly<z.ZodMiniObject<{
140
+ id: z.ZodMiniString<string>;
141
+ serviceId: z.ZodMiniString<string>;
142
+ categoryId: z.ZodMiniString<string>;
143
+ purposeId: z.ZodMiniString<string>;
144
+ consentVersion: z.ZodMiniInt;
145
+ }, z.core.$strict>>>>;
146
+ }, z.core.$strict>>;
147
+
148
+ /** A current use with no decision or a grant for a different consent version. */
149
+ declare type ConsentRequirement = Readonly<{
150
+ useId: string;
151
+ categoryId: string;
152
+ /** The version required by the current policy for this use. */
153
+ consentVersion: number;
154
+ reason: 'undecided' | 'consent-version-mismatch';
155
+ }>;
156
+
157
+ /** In-memory runtime; methods can be passed as callbacks without binding. */
158
+ declare type ConsentRuntime = Readonly<{
159
+ getSnapshot: () => ConsentSnapshot;
160
+ evaluate: (useId: string) => ConsentEvaluation;
161
+ /** Includes undecided uses and version-mismatched grants, not explicit denials. */
162
+ getMismatchedConsent: () => readonly ConsentRequirement[];
163
+ /**
164
+ * Replace all choices from trusted persistence, preserving unknown uses and recorded versions.
165
+ * Validation checks structure, not evidence of user consent; use decision methods for new choices.
166
+ * Does not replace policy, renew versions or perform I/O. Effective changes notify existing guards.
167
+ */
168
+ restoreState: (state: unknown) => ValidationResult<ConsentSnapshot>;
169
+ setConsentDecision: (command: ConsentDecisionCommand) => ValidationResult<ConsentSnapshot>;
170
+ setCategoryConsent: (command: CategoryConsentCommand) => ValidationResult<ConsentSnapshot>;
171
+ /** Validates all targets before one commit; observer errors can throw after that commit. */
172
+ setConsentDecisions: (command: ConsentDecisionsCommand) => ValidationResult<ConsentSnapshot>;
173
+ updatePolicy: (currentAppPolicy: unknown) => ValidationResult<ConsentSnapshot>;
174
+ subscribe: (listener: () => void) => () => void;
175
+ }>;
176
+
177
+ /** One active app policy and recorded choices; not a history of policies shown to users. */
178
+ declare type ConsentSnapshot = Readonly<{
179
+ currentAppPolicy: ConsentPolicy;
180
+ state: ConsentState;
181
+ }>;
182
+
183
+ declare type ConsentState = z.infer<typeof consentStateSchema>;
184
+
185
+ declare const consentStateSchema: z.ZodMiniReadonly<z.ZodMiniObject<{
186
+ choices: z.ZodMiniReadonly<z.ZodMiniArray<z.ZodMiniReadonly<z.ZodMiniObject<{
187
+ useId: z.ZodMiniString<string>;
188
+ consentVersion: z.ZodMiniInt;
189
+ decision: z.ZodMiniEnum<{
190
+ granted: "granted";
191
+ denied: "denied";
192
+ }>;
193
+ }, z.core.$strict>>>>;
194
+ }, z.core.$strict>>;
195
+
196
+ /** Explicit fetch guard; never intercepts global fetch or replays blocked requests. */
197
+ export declare function createConsentFetch({ consent, useId, fetch: fetchRequest }: ConsentFetchOptions): ConsentFetch;
198
+
199
+ declare type ExclusiveTarget<T> = T extends {
200
+ useId: string;
201
+ } ? T & {
202
+ readonly categoryId?: never;
203
+ } : T & {
204
+ readonly useId?: never;
205
+ };
206
+
207
+ /** A validation issue without a copy of the rejected input. */
208
+ declare type ValidationIssue = Readonly<{
209
+ code: string;
210
+ path: readonly (string | number)[];
211
+ message: string;
212
+ }>;
213
+
214
+ declare type ValidationResult<T> = Readonly<{
215
+ success: true;
216
+ data: T;
217
+ }> | Readonly<{
218
+ success: false;
219
+ issues: readonly ValidationIssue[];
220
+ }>;
221
+
222
+ export { }
@@ -0,0 +1,40 @@
1
+ import { t as ConsentEnforcementError } from "../ConsentEnforcementError-Bn_ayWJI.js";
2
+ import { n as retainSignal, t as createConsentRequestScope } from "../createConsentRequestScope-D7U8uK6m.js";
3
+ import { n as requireUseId, t as requireConsent } from "../validate-D16G7mdG.js";
4
+ //#region src/enforcement/fetch/ConsentFetchError.ts
5
+ /** Guard rejection or abort reason. Native response-body reads may instead throw AbortError. */
6
+ var ConsentFetchError = class extends ConsentEnforcementError {
7
+ name = "ConsentFetchError";
8
+ constructor(useId, reason) {
9
+ super(`Consent fetch blocked (${reason}).`, useId, reason);
10
+ }
11
+ };
12
+ //#endregion
13
+ //#region src/enforcement/fetch/createConsentFetch.ts
14
+ /** Explicit fetch guard; never intercepts global fetch or replays blocked requests. */
15
+ function createConsentFetch({ consent, useId, fetch: fetchRequest }) {
16
+ requireUseId(useId);
17
+ requireConsent(consent);
18
+ if (fetchRequest !== void 0 && typeof fetchRequest !== "function") throw new TypeError("Expected fetch.");
19
+ const scope = createConsentRequestScope(consent, useId, (reason) => new ConsentFetchError(useId, reason));
20
+ return Object.freeze({
21
+ async fetch(input, init) {
22
+ const grantSignal = scope.begin();
23
+ const request = new Request(input, init);
24
+ const signal = AbortSignal.any([request.signal, grantSignal]);
25
+ scope.assertAllowed();
26
+ signal.throwIfAborted();
27
+ const guardedInit = {
28
+ signal,
29
+ referrer: request.referrer,
30
+ referrerPolicy: request.referrerPolicy
31
+ };
32
+ const response = await (fetchRequest ? fetchRequest(request, guardedInit) : globalThis.fetch(request, guardedInit));
33
+ retainSignal(signal, response, response.body);
34
+ return response;
35
+ },
36
+ dispose: scope.dispose
37
+ });
38
+ }
39
+ //#endregion
40
+ export { ConsentFetchError, createConsentFetch };
@@ -0,0 +1,245 @@
1
+ import * as z from 'zod/mini';
2
+
3
+ /** Disjoint category/use decisions for one scope actually presented to the user. */
4
+ declare type BatchCommand = z.infer<typeof consentDecisionsCommandSchema>;
5
+
6
+ /** Records choices only for category members in userConsentedPolicy, not future members. */
7
+ declare type CategoryConsentCommand = z.infer<typeof categoryConsentCommandSchema>;
8
+
9
+ declare const categoryConsentCommandSchema: z.ZodMiniReadonly<z.ZodMiniObject<{
10
+ userConsentedPolicy: z.ZodMiniReadonly<z.ZodMiniObject<{
11
+ purposes: z.ZodMiniReadonly<z.ZodMiniArray<z.ZodMiniReadonly<z.ZodMiniObject<{
12
+ id: z.ZodMiniString<string>;
13
+ title: z.ZodMiniString<string>;
14
+ description: z.ZodMiniString<string>;
15
+ }, z.core.$strict>>>>;
16
+ uses: z.ZodMiniReadonly<z.ZodMiniArray<z.ZodMiniReadonly<z.ZodMiniObject<{
17
+ id: z.ZodMiniString<string>;
18
+ serviceId: z.ZodMiniString<string>;
19
+ categoryId: z.ZodMiniString<string>;
20
+ purposeId: z.ZodMiniString<string>;
21
+ consentVersion: z.ZodMiniInt;
22
+ }, z.core.$strict>>>>;
23
+ }, z.core.$strict>>;
24
+ categoryId: z.ZodMiniString<string>;
25
+ decision: z.ZodMiniEnum<{
26
+ granted: "granted";
27
+ denied: "denied";
28
+ }>;
29
+ }, z.core.$strict>>;
30
+
31
+ /** userConsentedPolicy is the scope shown for this decision, including a denial. */
32
+ declare type ConsentDecisionCommand = z.infer<typeof consentDecisionCommandSchema>;
33
+
34
+ declare const consentDecisionCommandSchema: z.ZodMiniReadonly<z.ZodMiniObject<{
35
+ userConsentedPolicy: z.ZodMiniReadonly<z.ZodMiniObject<{
36
+ purposes: z.ZodMiniReadonly<z.ZodMiniArray<z.ZodMiniReadonly<z.ZodMiniObject<{
37
+ id: z.ZodMiniString<string>;
38
+ title: z.ZodMiniString<string>;
39
+ description: z.ZodMiniString<string>;
40
+ }, z.core.$strict>>>>;
41
+ uses: z.ZodMiniReadonly<z.ZodMiniArray<z.ZodMiniReadonly<z.ZodMiniObject<{
42
+ id: z.ZodMiniString<string>;
43
+ serviceId: z.ZodMiniString<string>;
44
+ categoryId: z.ZodMiniString<string>;
45
+ purposeId: z.ZodMiniString<string>;
46
+ consentVersion: z.ZodMiniInt;
47
+ }, z.core.$strict>>>>;
48
+ }, z.core.$strict>>;
49
+ useId: z.ZodMiniString<string>;
50
+ decision: z.ZodMiniEnum<{
51
+ granted: "granted";
52
+ denied: "denied";
53
+ }>;
54
+ }, z.core.$strict>>;
55
+
56
+ declare type ConsentDecisionsCommand = Readonly<Omit<BatchCommand, 'decisions'> & {
57
+ decisions: readonly ExclusiveTarget<BatchCommand['decisions'][number]>[];
58
+ }>;
59
+
60
+ declare const consentDecisionsCommandSchema: z.ZodMiniReadonly<z.ZodMiniObject<{
61
+ userConsentedPolicy: z.ZodMiniReadonly<z.ZodMiniObject<{
62
+ purposes: z.ZodMiniReadonly<z.ZodMiniArray<z.ZodMiniReadonly<z.ZodMiniObject<{
63
+ id: z.ZodMiniString<string>;
64
+ title: z.ZodMiniString<string>;
65
+ description: z.ZodMiniString<string>;
66
+ }, z.core.$strict>>>>;
67
+ uses: z.ZodMiniReadonly<z.ZodMiniArray<z.ZodMiniReadonly<z.ZodMiniObject<{
68
+ id: z.ZodMiniString<string>;
69
+ serviceId: z.ZodMiniString<string>;
70
+ categoryId: z.ZodMiniString<string>;
71
+ purposeId: z.ZodMiniString<string>;
72
+ consentVersion: z.ZodMiniInt;
73
+ }, z.core.$strict>>>>;
74
+ }, z.core.$strict>>;
75
+ decisions: z.ZodMiniReadonly<z.ZodMiniArray<z.ZodMiniUnion<readonly [z.ZodMiniReadonly<z.ZodMiniObject<{
76
+ useId: z.ZodMiniString<string>;
77
+ decision: z.ZodMiniEnum<{
78
+ granted: "granted";
79
+ denied: "denied";
80
+ }>;
81
+ }, z.core.$strict>>, z.ZodMiniReadonly<z.ZodMiniObject<{
82
+ categoryId: z.ZodMiniString<string>;
83
+ decision: z.ZodMiniEnum<{
84
+ granted: "granted";
85
+ denied: "denied";
86
+ }>;
87
+ }, z.core.$strict>>]>>>;
88
+ }, z.core.$strict>>;
89
+
90
+ declare type ConsentDeniedReason = 'unknown-use' | 'undecided' | 'denied' | 'consent-version-mismatch';
91
+
92
+ /**
93
+ * Shared shape for enforcement guard errors. Only the concrete classes are public: each subpath
94
+ * exports exactly one of them, so consumers keep their own `instanceof` and literal `name` type.
95
+ */
96
+ declare abstract class ConsentEnforcementError<Reason extends string> extends Error {
97
+ readonly useId: string;
98
+ readonly reason: Reason;
99
+ constructor(message: string, useId: string, reason: Reason);
100
+ }
101
+
102
+ declare type ConsentEvaluation = Readonly<{
103
+ allowed: true;
104
+ }> | Readonly<{
105
+ allowed: false;
106
+ reason: ConsentDeniedReason;
107
+ }>;
108
+
109
+ export declare type ConsentIframe = Readonly<{
110
+ /** Throws if blocked. Mounting does not confirm successful remote content loading. */
111
+ mount: (options: ConsentIframeMountOptions) => ConsentIframeHandle;
112
+ dispose: () => void;
113
+ }>;
114
+
115
+ export declare class ConsentIframeError extends ConsentEnforcementError<ConsentIframeErrorReason> {
116
+ readonly name = "ConsentIframeError";
117
+ constructor(useId: string, reason: ConsentIframeErrorReason);
118
+ }
119
+
120
+ export declare type ConsentIframeErrorReason = ConsentDeniedReason | 'disposed' | 'removed';
121
+
122
+ export declare type ConsentIframeHandle = Readonly<{
123
+ element: HTMLIFrameElement;
124
+ /** Replaces presentation without navigation; throws if this mount is no longer permitted/live. */
125
+ updatePresentation: (options: ConsentIframePresentationOptions) => void;
126
+ /** Destroys this frame's browsing context by removing its element. */
127
+ remove: () => void;
128
+ }>;
129
+
130
+ export declare type ConsentIframeMountOptions = ConsentIframePresentationOptions & Readonly<{
131
+ /** External HTTP(S) URL; no srcdoc or inline/data documents. */
132
+ src: string;
133
+ parent: HTMLElement;
134
+ /** Explicit sandbox tokens; omitted means native unsandboxed behavior. Empty string restricts all. */
135
+ sandbox?: string;
136
+ allow?: string;
137
+ referrerPolicy?: ReferrerPolicy;
138
+ loading?: 'eager' | 'lazy';
139
+ }>;
140
+
141
+ export declare type ConsentIframeOptions = Readonly<{
142
+ consent: Pick<ConsentRuntime, 'evaluate' | 'subscribe'>;
143
+ useId: string;
144
+ }>;
145
+
146
+ export declare type ConsentIframePresentationOptions = Readonly<{
147
+ /** Required accessible name. */
148
+ title: string;
149
+ /** Omission removes the corresponding dimension attribute. */
150
+ width?: string;
151
+ height?: string;
152
+ }>;
153
+
154
+ declare type ConsentPolicy = z.infer<typeof consentPolicySchema>;
155
+
156
+ declare const consentPolicySchema: z.ZodMiniReadonly<z.ZodMiniObject<{
157
+ purposes: z.ZodMiniReadonly<z.ZodMiniArray<z.ZodMiniReadonly<z.ZodMiniObject<{
158
+ id: z.ZodMiniString<string>;
159
+ title: z.ZodMiniString<string>;
160
+ description: z.ZodMiniString<string>;
161
+ }, z.core.$strict>>>>;
162
+ uses: z.ZodMiniReadonly<z.ZodMiniArray<z.ZodMiniReadonly<z.ZodMiniObject<{
163
+ id: z.ZodMiniString<string>;
164
+ serviceId: z.ZodMiniString<string>;
165
+ categoryId: z.ZodMiniString<string>;
166
+ purposeId: z.ZodMiniString<string>;
167
+ consentVersion: z.ZodMiniInt;
168
+ }, z.core.$strict>>>>;
169
+ }, z.core.$strict>>;
170
+
171
+ /** A current use with no decision or a grant for a different consent version. */
172
+ declare type ConsentRequirement = Readonly<{
173
+ useId: string;
174
+ categoryId: string;
175
+ /** The version required by the current policy for this use. */
176
+ consentVersion: number;
177
+ reason: 'undecided' | 'consent-version-mismatch';
178
+ }>;
179
+
180
+ /** In-memory runtime; methods can be passed as callbacks without binding. */
181
+ declare type ConsentRuntime = Readonly<{
182
+ getSnapshot: () => ConsentSnapshot;
183
+ evaluate: (useId: string) => ConsentEvaluation;
184
+ /** Includes undecided uses and version-mismatched grants, not explicit denials. */
185
+ getMismatchedConsent: () => readonly ConsentRequirement[];
186
+ /**
187
+ * Replace all choices from trusted persistence, preserving unknown uses and recorded versions.
188
+ * Validation checks structure, not evidence of user consent; use decision methods for new choices.
189
+ * Does not replace policy, renew versions or perform I/O. Effective changes notify existing guards.
190
+ */
191
+ restoreState: (state: unknown) => ValidationResult<ConsentSnapshot>;
192
+ setConsentDecision: (command: ConsentDecisionCommand) => ValidationResult<ConsentSnapshot>;
193
+ setCategoryConsent: (command: CategoryConsentCommand) => ValidationResult<ConsentSnapshot>;
194
+ /** Validates all targets before one commit; observer errors can throw after that commit. */
195
+ setConsentDecisions: (command: ConsentDecisionsCommand) => ValidationResult<ConsentSnapshot>;
196
+ updatePolicy: (currentAppPolicy: unknown) => ValidationResult<ConsentSnapshot>;
197
+ subscribe: (listener: () => void) => () => void;
198
+ }>;
199
+
200
+ /** One active app policy and recorded choices; not a history of policies shown to users. */
201
+ declare type ConsentSnapshot = Readonly<{
202
+ currentAppPolicy: ConsentPolicy;
203
+ state: ConsentState;
204
+ }>;
205
+
206
+ declare type ConsentState = z.infer<typeof consentStateSchema>;
207
+
208
+ declare const consentStateSchema: z.ZodMiniReadonly<z.ZodMiniObject<{
209
+ choices: z.ZodMiniReadonly<z.ZodMiniArray<z.ZodMiniReadonly<z.ZodMiniObject<{
210
+ useId: z.ZodMiniString<string>;
211
+ consentVersion: z.ZodMiniInt;
212
+ decision: z.ZodMiniEnum<{
213
+ granted: "granted";
214
+ denied: "denied";
215
+ }>;
216
+ }, z.core.$strict>>>>;
217
+ }, z.core.$strict>>;
218
+
219
+ /** Owns only frames explicitly mounted through this guard; never scans or patches the page. */
220
+ export declare function createConsentIframe({ consent, useId }: ConsentIframeOptions): ConsentIframe;
221
+
222
+ declare type ExclusiveTarget<T> = T extends {
223
+ useId: string;
224
+ } ? T & {
225
+ readonly categoryId?: never;
226
+ } : T & {
227
+ readonly useId?: never;
228
+ };
229
+
230
+ /** A validation issue without a copy of the rejected input. */
231
+ declare type ValidationIssue = Readonly<{
232
+ code: string;
233
+ path: readonly (string | number)[];
234
+ message: string;
235
+ }>;
236
+
237
+ declare type ValidationResult<T> = Readonly<{
238
+ success: true;
239
+ data: T;
240
+ }> | Readonly<{
241
+ success: false;
242
+ issues: readonly ValidationIssue[];
243
+ }>;
244
+
245
+ export { }
@@ -0,0 +1,2 @@
1
+ import { n as ConsentIframeError, t as createConsentIframe } from "../createConsentIframe-Bw-cl--m.js";
2
+ export { ConsentIframeError, createConsentIframe };