@monterosa/sdk-consent-kit 2.0.0-rc.1

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/dist/api.d.ts ADDED
@@ -0,0 +1,107 @@
1
+ /**
2
+ * @license
3
+ * @monterosa/sdk-consent-kit
4
+ *
5
+ * Copyright © 2026 Monterosa Productions Limited. All rights reserved.
6
+ *
7
+ * More details on the license can be found at https://www.monterosa.co/sdk/license
8
+ */
9
+ import { Unsubscribe } from '@monterosa/sdk-util';
10
+ import { ConsentState, ConsentKit, ConsentHook } from './types';
11
+ /**
12
+ * Get the consent kit instance.
13
+ *
14
+ * @returns The consent kit instance.
15
+ *
16
+ * @internal
17
+ */
18
+ export declare function getConsent(): ConsentKit;
19
+ /**
20
+ * Register a hook that will be called when consent is initialized.
21
+ *
22
+ * @param hook - The hook function to register.
23
+ *
24
+ * @internal
25
+ */
26
+ export declare function registerConsentHook(hook: ConsentHook): void;
27
+ /**
28
+ * Set the consent state.
29
+ *
30
+ * @remarks
31
+ * - The 'necessary' category cannot be set to false
32
+ * - Cannot be called from a child experience (use parent application instead)
33
+ *
34
+ * @example
35
+ * ```typescript
36
+ * setConsentState({
37
+ * necessary: true,
38
+ * analytics: true,
39
+ * marketing: false,
40
+ * functional: true,
41
+ * });
42
+ * ```
43
+ *
44
+ * @param state - The consent state to set
45
+ * @throws {MonterosaError} If called from a child experience
46
+ * @throws {MonterosaError} If 'necessary' category is set to false
47
+ */
48
+ export declare function setConsentState<T extends string = string>(state: ConsentState<T>): void;
49
+ /**
50
+ * Get the current consent state.
51
+ *
52
+ * @example
53
+ * ```typescript
54
+ * const state = getConsentState();
55
+ * if (state.analytics) {
56
+ * // Analytics consent granted
57
+ * }
58
+ * ```
59
+ *
60
+ * @returns The current consent state, or empty object if consent mode not active
61
+ */
62
+ export declare function getConsentState<T extends string = string>(): ConsentState<T>;
63
+ /**
64
+ * Check if consent is granted for a specific category.
65
+ *
66
+ * @remarks
67
+ * - The 'necessary' category always returns true
68
+ * - Returns true if consent mode is not active (backwards compatibility)
69
+ * - Returns false for missing keys when consent mode is active (GDPR strict opt-in)
70
+ * - Returns the boolean value if the category exists in consent state
71
+ *
72
+ * @example
73
+ * ```typescript
74
+ * if (hasConsent('analytics')) {
75
+ * // Track analytics event
76
+ * }
77
+ * ```
78
+ *
79
+ * @param category - The consent category to check
80
+ * @returns Whether consent is granted for the category
81
+ */
82
+ export declare function hasConsent(category: string): boolean;
83
+ /**
84
+ * Subscribe to consent state changes.
85
+ *
86
+ * @example
87
+ * ```typescript
88
+ * const unsubscribe = onConsentChanged((state) => {
89
+ * console.log('Consent changed:', state);
90
+ * });
91
+ *
92
+ * // Later, to stop listening:
93
+ * unsubscribe();
94
+ * ```
95
+ *
96
+ * @param callback - The callback to call when consent state changes
97
+ * @returns A function to unsubscribe from the event
98
+ */
99
+ export declare function onConsentChanged<T extends string = string>(callback: (state: ConsentState<T>) => void): Unsubscribe;
100
+ /**
101
+ * Update consent state from parent (used internally by bridge).
102
+ *
103
+ * @param state - The consent state received from parent
104
+ *
105
+ * @internal
106
+ */
107
+ export declare function updateConsentFromParent<T extends string = string>(state: ConsentState<T>): void;
@@ -0,0 +1,40 @@
1
+ /**
2
+ * @license
3
+ * @monterosa/sdk-consent-kit
4
+ *
5
+ * Copyright © 2026 Monterosa Productions Limited. All rights reserved.
6
+ *
7
+ * More details on the license can be found at https://www.monterosa.co/sdk/license
8
+ */
9
+ import { Unsubscribe } from '@monterosa/sdk-util';
10
+ import { Experience } from '@monterosa/sdk-launcher-kit';
11
+ import { ConsentKit } from './types';
12
+ /**
13
+ * Handle when an experience is embedded.
14
+ * Sends current consent state to the child (queued by the bridge until
15
+ * the experience is initialised) and subscribes to consent changes.
16
+ *
17
+ * @param experience - The embedded experience
18
+ *
19
+ * @internal
20
+ */
21
+ export declare function handleExperienceEmbedded(experience: Experience): void;
22
+ /**
23
+ * Handle when an experience is unmounted.
24
+ * Cleans up subscriptions for the experience.
25
+ *
26
+ * @param experience - The unmounted experience
27
+ *
28
+ * @internal
29
+ */
30
+ export declare function handleExperienceUnmounted(experience: Experience): void;
31
+ /**
32
+ * Hook to listen for consent messages from parent application.
33
+ * This is called when consent-kit is initialized in a child experience.
34
+ *
35
+ * @param consent - The consent kit instance
36
+ * @returns Unsubscribe function
37
+ *
38
+ * @internal
39
+ */
40
+ export declare function parentMessagesHook(consent: ConsentKit): Unsubscribe;
@@ -0,0 +1,46 @@
1
+ /**
2
+ * @license
3
+ * @monterosa/sdk-consent-kit
4
+ *
5
+ * Copyright © 2026 Monterosa Productions Limited. All rights reserved.
6
+ *
7
+ * More details on the license can be found at https://www.monterosa.co/sdk/license
8
+ */
9
+ import { Emitter } from '@monterosa/sdk-util';
10
+ import { ConsentKit, ConsentState } from './types';
11
+ /**
12
+ * Internal Consent class that manages consent state.
13
+ *
14
+ * @internal
15
+ */
16
+ export declare class Consent extends Emitter implements ConsentKit {
17
+ private static instance;
18
+ private _state;
19
+ /**
20
+ * The current consent state.
21
+ * Setting this value will automatically emit ConsentChanged event if the state
22
+ * actually changed.
23
+ */
24
+ get state(): ConsentState | null;
25
+ set state(value: ConsentState | null);
26
+ /**
27
+ * Whether consent mode is active.
28
+ * Returns true when state has been set.
29
+ */
30
+ get isActive(): boolean;
31
+ private constructor();
32
+ /**
33
+ * Compare two consent states for equality.
34
+ *
35
+ * @param a - First consent state (or null)
36
+ * @param b - Second consent state (or null)
37
+ * @returns Whether the states are equal
38
+ */
39
+ private static isConsentStateEqual;
40
+ /**
41
+ * Get the singleton instance of the Consent class.
42
+ *
43
+ * @returns The Consent singleton instance.
44
+ */
45
+ static getInstance(): Consent;
46
+ }
@@ -0,0 +1,460 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var sdkLauncherKit = require('@monterosa/sdk-launcher-kit');
6
+ var sdkUtil = require('@monterosa/sdk-util');
7
+
8
+ /**
9
+ * @license
10
+ * @monterosa/sdk-consent-kit
11
+ *
12
+ * Copyright © 2026 Monterosa Productions Limited. All rights reserved.
13
+ *
14
+ * More details on the license can be found at https://www.monterosa.co/sdk/license
15
+ */
16
+ var _a;
17
+ /**
18
+ * Actions used for parent-child bridge communication.
19
+ *
20
+ * @internal
21
+ */
22
+ var ConsentAction;
23
+ (function (ConsentAction) {
24
+ /**
25
+ * Sent when consent state is updated.
26
+ */
27
+ ConsentAction["OnConsentUpdated"] = "consentOnConsentUpdated";
28
+ /**
29
+ * Request to set consent state from child to parent.
30
+ */
31
+ ConsentAction["SetConsent"] = "consentSetConsent";
32
+ })(ConsentAction || (ConsentAction = {}));
33
+ /**
34
+ * Internal event names for the consent emitter.
35
+ *
36
+ * @internal
37
+ */
38
+ var ConsentEvent;
39
+ (function (ConsentEvent) {
40
+ /**
41
+ * Emitted when consent state changes.
42
+ */
43
+ ConsentEvent["ConsentChanged"] = "consent_changed";
44
+ })(ConsentEvent || (ConsentEvent = {}));
45
+ /**
46
+ * Defines error codes that may be encountered when using the Consent kit.
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * try {
51
+ * setConsentState({ necessary: false });
52
+ * } catch (err) {
53
+ * if (err.code === ConsentError.NecessaryCategoryRequired) {
54
+ * // handle necessary category error
55
+ * }
56
+ * }
57
+ * ```
58
+ */
59
+ exports.ConsentError = void 0;
60
+ (function (ConsentError) {
61
+ /**
62
+ * Indicates that the 'necessary' category cannot be set to false.
63
+ */
64
+ ConsentError["NecessaryCategoryRequired"] = "necessary_category_required";
65
+ /**
66
+ * Indicates that consent cannot be set from a child experience.
67
+ */
68
+ ConsentError["CannotSetFromChild"] = "cannot_set_from_child";
69
+ })(exports.ConsentError || (exports.ConsentError = {}));
70
+ /**
71
+ * Error messages for consent errors.
72
+ *
73
+ * @internal
74
+ */
75
+ var ConsentErrorMessages = (_a = {},
76
+ _a[exports.ConsentError.NecessaryCategoryRequired] = function () {
77
+ return "Cannot set 'necessary' category to false. Strictly necessary functionality cannot be disabled.";
78
+ },
79
+ _a[exports.ConsentError.CannotSetFromChild] = function () {
80
+ return 'Cannot set consent state from embedded experience. Consent is managed by the parent application.';
81
+ },
82
+ _a);
83
+
84
+ /******************************************************************************
85
+ Copyright (c) Microsoft Corporation.
86
+
87
+ Permission to use, copy, modify, and/or distribute this software for any
88
+ purpose with or without fee is hereby granted.
89
+
90
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
91
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
92
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
93
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
94
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
95
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
96
+ PERFORMANCE OF THIS SOFTWARE.
97
+ ***************************************************************************** */
98
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
99
+
100
+ var extendStatics = function(d, b) {
101
+ extendStatics = Object.setPrototypeOf ||
102
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
103
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
104
+ return extendStatics(d, b);
105
+ };
106
+
107
+ function __extends(d, b) {
108
+ if (typeof b !== "function" && b !== null)
109
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
110
+ extendStatics(d, b);
111
+ function __() { this.constructor = d; }
112
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
113
+ }
114
+
115
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
116
+ var e = new Error(message);
117
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
118
+ };
119
+
120
+ /**
121
+ * @license
122
+ * @monterosa/sdk-consent-kit
123
+ *
124
+ * Copyright © 2026 Monterosa Productions Limited. All rights reserved.
125
+ *
126
+ * More details on the license can be found at https://www.monterosa.co/sdk/license
127
+ */
128
+ /**
129
+ * Internal Consent class that manages consent state.
130
+ *
131
+ * @internal
132
+ */
133
+ var Consent = /** @class */ (function (_super) {
134
+ __extends(Consent, _super);
135
+ function Consent() {
136
+ var _this = _super.call(this) || this;
137
+ _this._state = null;
138
+ return _this;
139
+ }
140
+ Object.defineProperty(Consent.prototype, "state", {
141
+ /**
142
+ * The current consent state.
143
+ * Setting this value will automatically emit ConsentChanged event if the state
144
+ * actually changed.
145
+ */
146
+ get: function () {
147
+ return this._state;
148
+ },
149
+ set: function (value) {
150
+ var previousState = this._state;
151
+ this._state = value;
152
+ // Only emit if state changed to a non-null value
153
+ if (value !== null && !Consent.isConsentStateEqual(previousState, value)) {
154
+ this.emit(ConsentEvent.ConsentChanged, value);
155
+ }
156
+ },
157
+ enumerable: false,
158
+ configurable: true
159
+ });
160
+ Object.defineProperty(Consent.prototype, "isActive", {
161
+ /**
162
+ * Whether consent mode is active.
163
+ * Returns true when state has been set.
164
+ */
165
+ get: function () {
166
+ return this._state !== null;
167
+ },
168
+ enumerable: false,
169
+ configurable: true
170
+ });
171
+ /**
172
+ * Compare two consent states for equality.
173
+ *
174
+ * @param a - First consent state (or null)
175
+ * @param b - Second consent state (or null)
176
+ * @returns Whether the states are equal
177
+ */
178
+ Consent.isConsentStateEqual = function (a, b) {
179
+ if (a === null && b === null)
180
+ return true;
181
+ if (a === null || b === null)
182
+ return false;
183
+ var keysA = Object.keys(a);
184
+ var keysB = Object.keys(b);
185
+ if (keysA.length !== keysB.length)
186
+ return false;
187
+ var aRecord = a;
188
+ var bRecord = b;
189
+ return keysA.every(function (key) { return aRecord[key] === bRecord[key]; });
190
+ };
191
+ /**
192
+ * Get the singleton instance of the Consent class.
193
+ *
194
+ * @returns The Consent singleton instance.
195
+ */
196
+ Consent.getInstance = function () {
197
+ if (!Consent.instance) {
198
+ Consent.instance = new Consent();
199
+ }
200
+ return Consent.instance;
201
+ };
202
+ return Consent;
203
+ }(sdkUtil.Emitter));
204
+
205
+ /**
206
+ * @license
207
+ * @monterosa/sdk-consent-kit
208
+ *
209
+ * Copyright © 2026 Monterosa Productions Limited. All rights reserved.
210
+ *
211
+ * More details on the license can be found at https://www.monterosa.co/sdk/license
212
+ */
213
+ var consentHooks = [];
214
+ var hooksRegistered = false;
215
+ /**
216
+ * Get the consent kit instance.
217
+ *
218
+ * @returns The consent kit instance.
219
+ *
220
+ * @internal
221
+ */
222
+ function getConsent() {
223
+ var consent = Consent.getInstance();
224
+ if (!hooksRegistered) {
225
+ // Register hooks only once
226
+ for (var _i = 0, consentHooks_1 = consentHooks; _i < consentHooks_1.length; _i++) {
227
+ var hook = consentHooks_1[_i];
228
+ hook(consent);
229
+ }
230
+ hooksRegistered = true;
231
+ }
232
+ return consent;
233
+ }
234
+ /**
235
+ * Register a hook that will be called when consent is initialized.
236
+ *
237
+ * @param hook - The hook function to register.
238
+ *
239
+ * @internal
240
+ */
241
+ function registerConsentHook(hook) {
242
+ consentHooks.push(hook);
243
+ }
244
+ /**
245
+ * Set the consent state.
246
+ *
247
+ * @remarks
248
+ * - The 'necessary' category cannot be set to false
249
+ * - Cannot be called from a child experience (use parent application instead)
250
+ *
251
+ * @example
252
+ * ```typescript
253
+ * setConsentState({
254
+ * necessary: true,
255
+ * analytics: true,
256
+ * marketing: false,
257
+ * functional: true,
258
+ * });
259
+ * ```
260
+ *
261
+ * @param state - The consent state to set
262
+ * @throws {MonterosaError} If called from a child experience
263
+ * @throws {MonterosaError} If 'necessary' category is set to false
264
+ */
265
+ function setConsentState(state) {
266
+ var parentApp = sdkLauncherKit.getParentApplication();
267
+ // Cannot set consent from a child experience
268
+ if (parentApp !== null) {
269
+ throw new sdkUtil.MonterosaError(exports.ConsentError.CannotSetFromChild, ConsentErrorMessages[exports.ConsentError.CannotSetFromChild]());
270
+ }
271
+ // Necessary category cannot be false
272
+ if ('necessary' in state && state.necessary === false) {
273
+ throw new sdkUtil.MonterosaError(exports.ConsentError.NecessaryCategoryRequired, ConsentErrorMessages[exports.ConsentError.NecessaryCategoryRequired]());
274
+ }
275
+ var consent = getConsent();
276
+ consent.state = state;
277
+ }
278
+ /**
279
+ * Get the current consent state.
280
+ *
281
+ * @example
282
+ * ```typescript
283
+ * const state = getConsentState();
284
+ * if (state.analytics) {
285
+ * // Analytics consent granted
286
+ * }
287
+ * ```
288
+ *
289
+ * @returns The current consent state, or empty object if consent mode not active
290
+ */
291
+ function getConsentState() {
292
+ var _a;
293
+ return ((_a = getConsent().state) !== null && _a !== void 0 ? _a : {});
294
+ }
295
+ /**
296
+ * Check if consent is granted for a specific category.
297
+ *
298
+ * @remarks
299
+ * - The 'necessary' category always returns true
300
+ * - Returns true if consent mode is not active (backwards compatibility)
301
+ * - Returns false for missing keys when consent mode is active (GDPR strict opt-in)
302
+ * - Returns the boolean value if the category exists in consent state
303
+ *
304
+ * @example
305
+ * ```typescript
306
+ * if (hasConsent('analytics')) {
307
+ * // Track analytics event
308
+ * }
309
+ * ```
310
+ *
311
+ * @param category - The consent category to check
312
+ * @returns Whether consent is granted for the category
313
+ */
314
+ function hasConsent(category) {
315
+ var _a;
316
+ // 'necessary' always returns true
317
+ if (category === 'necessary') {
318
+ return true;
319
+ }
320
+ var consent = getConsent();
321
+ // If consent mode not active, allow everything (backwards compatibility)
322
+ if (!consent.isActive) {
323
+ return true;
324
+ }
325
+ // GDPR strict opt-in: missing keys default to false
326
+ return (((_a = consent.state) === null || _a === void 0 ? void 0 : _a[category]) === true);
327
+ }
328
+ /**
329
+ * Subscribe to consent state changes.
330
+ *
331
+ * @example
332
+ * ```typescript
333
+ * const unsubscribe = onConsentChanged((state) => {
334
+ * console.log('Consent changed:', state);
335
+ * });
336
+ *
337
+ * // Later, to stop listening:
338
+ * unsubscribe();
339
+ * ```
340
+ *
341
+ * @param callback - The callback to call when consent state changes
342
+ * @returns A function to unsubscribe from the event
343
+ */
344
+ function onConsentChanged(callback) {
345
+ var consent = getConsent();
346
+ return consent.on(ConsentEvent.ConsentChanged, callback);
347
+ }
348
+ /**
349
+ * Update consent state from parent (used internally by bridge).
350
+ *
351
+ * @param state - The consent state received from parent
352
+ *
353
+ * @internal
354
+ */
355
+ function updateConsentFromParent(state) {
356
+ var consent = getConsent();
357
+ consent.state = state;
358
+ }
359
+
360
+ /**
361
+ * @license
362
+ * @monterosa/sdk-consent-kit
363
+ *
364
+ * Copyright © 2026 Monterosa Productions Limited. All rights reserved.
365
+ *
366
+ * More details on the license can be found at https://www.monterosa.co/sdk/license
367
+ */
368
+ var experienceUnsubs = new Map();
369
+ /**
370
+ * Handle when an experience is embedded.
371
+ * Sends current consent state to the child (queued by the bridge until
372
+ * the experience is initialised) and subscribes to consent changes.
373
+ *
374
+ * @param experience - The embedded experience
375
+ *
376
+ * @internal
377
+ */
378
+ function handleExperienceEmbedded(experience) {
379
+ var consent = getConsent();
380
+ // Send current consent state if active.
381
+ // The bridge queues this message until the experience is initialised.
382
+ if (consent.isActive) {
383
+ sdkLauncherKit.sendSdkMessage(experience, ConsentAction.OnConsentUpdated, {
384
+ state: consent.state,
385
+ });
386
+ }
387
+ // Subscribe to consent changes and push to child
388
+ var consentChangedUnsub = onConsentChanged(function (state) {
389
+ sdkLauncherKit.sendSdkMessage(experience, ConsentAction.OnConsentUpdated, {
390
+ state: state,
391
+ });
392
+ });
393
+ experienceUnsubs.set(experience.id, [consentChangedUnsub]);
394
+ }
395
+ /**
396
+ * Handle when an experience is unmounted.
397
+ * Cleans up subscriptions for the experience.
398
+ *
399
+ * @param experience - The unmounted experience
400
+ *
401
+ * @internal
402
+ */
403
+ function handleExperienceUnmounted(experience) {
404
+ var unsubs = experienceUnsubs.get(experience.id);
405
+ if (unsubs) {
406
+ for (var _i = 0, unsubs_1 = unsubs; _i < unsubs_1.length; _i++) {
407
+ var unsub = unsubs_1[_i];
408
+ unsub();
409
+ }
410
+ experienceUnsubs.delete(experience.id);
411
+ }
412
+ }
413
+ /**
414
+ * Hook to listen for consent messages from parent application.
415
+ * This is called when consent-kit is initialized in a child experience.
416
+ *
417
+ * @param consent - The consent kit instance
418
+ * @returns Unsubscribe function
419
+ *
420
+ * @internal
421
+ */
422
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
423
+ function parentMessagesHook(consent) {
424
+ var parentApp = sdkLauncherKit.getParentApplication();
425
+ if (parentApp === null) {
426
+ return function () { };
427
+ }
428
+ return sdkLauncherKit.onSdkMessage(parentApp, function (message) {
429
+ if (message.action === ConsentAction.OnConsentUpdated) {
430
+ var state = message.payload.state;
431
+ updateConsentFromParent(state);
432
+ }
433
+ });
434
+ }
435
+
436
+ /**
437
+ * @license
438
+ * @monterosa/sdk-consent-kit
439
+ *
440
+ * Copyright © 2026 Monterosa Productions Limited. All rights reserved.
441
+ *
442
+ * More details on the license can be found at https://www.monterosa.co/sdk/license
443
+ */
444
+ // Register bridge handlers for parent-child communication
445
+ sdkLauncherKit.onStateChanged(function (experience, state) {
446
+ if (state === 'mounted') {
447
+ handleExperienceEmbedded(experience);
448
+ }
449
+ else if (state === 'unmounted') {
450
+ handleExperienceUnmounted(experience);
451
+ }
452
+ });
453
+ // Register hook for child experiences to receive consent from parent
454
+ registerConsentHook(parentMessagesHook);
455
+
456
+ exports.getConsentState = getConsentState;
457
+ exports.hasConsent = hasConsent;
458
+ exports.onConsentChanged = onConsentChanged;
459
+ exports.setConsentState = setConsentState;
460
+ //# sourceMappingURL=index.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs.js","sources":["../src/types.ts","../src/consent.ts","../src/api.ts","../src/bridge.ts","../src/index.ts"],"sourcesContent":["/**\n * @license\n * @monterosa/sdk-consent-kit\n *\n * Copyright © 2026 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { Emitter, Unsubscribe } from '@monterosa/sdk-util';\n\n/**\n * Default consent categories commonly used for GDPR/privacy compliance.\n *\n * @remarks\n * - `necessary` - Essential cookies/tracking required for the site to function\n * - `analytics` - Analytics and performance tracking\n * - `marketing` - Marketing and advertising tracking\n * - `functional` - User preference and personalization tracking\n */\nexport type DefaultCategory =\n | 'necessary'\n | 'analytics'\n | 'marketing'\n | 'functional';\n\n/**\n * Represents the consent state for each category.\n * Maps category names to boolean values indicating whether consent is granted.\n *\n * @typeParam T - The type of category keys, defaults to DefaultCategory\n *\n * @example\n * ```typescript\n * const state: ConsentState = {\n * necessary: true,\n * analytics: false,\n * marketing: false,\n * preferences: true,\n * };\n * ```\n */\nexport type ConsentState<T extends string = DefaultCategory> = {\n [K in T]?: boolean;\n};\n\n/**\n * Actions used for parent-child bridge communication.\n *\n * @internal\n */\nexport enum ConsentAction {\n /**\n * Sent when consent state is updated.\n */\n OnConsentUpdated = 'consentOnConsentUpdated',\n /**\n * Request to set consent state from child to parent.\n */\n SetConsent = 'consentSetConsent',\n}\n\n/**\n * Internal event names for the consent emitter.\n *\n * @internal\n */\nexport enum ConsentEvent {\n /**\n * Emitted when consent state changes.\n */\n ConsentChanged = 'consent_changed',\n}\n\n/**\n * Defines error codes that may be encountered when using the Consent kit.\n *\n * @example\n * ```typescript\n * try {\n * setConsentState({ necessary: false });\n * } catch (err) {\n * if (err.code === ConsentError.NecessaryCategoryRequired) {\n * // handle necessary category error\n * }\n * }\n * ```\n */\nexport enum ConsentError {\n /**\n * Indicates that the 'necessary' category cannot be set to false.\n */\n NecessaryCategoryRequired = 'necessary_category_required',\n /**\n * Indicates that consent cannot be set from a child experience.\n */\n CannotSetFromChild = 'cannot_set_from_child',\n}\n\n/**\n * Error messages for consent errors.\n *\n * @internal\n */\nexport const ConsentErrorMessages = {\n [ConsentError.NecessaryCategoryRequired]: () =>\n \"Cannot set 'necessary' category to false. Strictly necessary functionality cannot be disabled.\",\n [ConsentError.CannotSetFromChild]: () =>\n 'Cannot set consent state from embedded experience. Consent is managed by the parent application.',\n};\n\n/**\n * Hook function type for registering consent hooks.\n *\n * @internal\n */\nexport type ConsentHook = (consent: ConsentKit) => Unsubscribe;\n\n/**\n * The ConsentKit interface provides properties and methods\n * for managing user consent state.\n *\n * @internal\n */\nexport interface ConsentKit extends Emitter {\n /**\n * Whether consent mode is active.\n * Returns true when state has been set.\n */\n readonly isActive: boolean;\n /**\n * The current consent state.\n */\n state: ConsentState | null;\n}\n","/**\n * @license\n * @monterosa/sdk-consent-kit\n *\n * Copyright © 2026 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { Emitter } from '@monterosa/sdk-util';\n\nimport { ConsentKit, ConsentState, ConsentEvent } from './types';\n\n/**\n * Internal Consent class that manages consent state.\n *\n * @internal\n */\nexport class Consent extends Emitter implements ConsentKit {\n private static instance: Consent;\n\n private _state: ConsentState | null = null;\n\n /**\n * The current consent state.\n * Setting this value will automatically emit ConsentChanged event if the state\n * actually changed.\n */\n get state(): ConsentState | null {\n return this._state;\n }\n\n set state(value: ConsentState | null) {\n const previousState = this._state;\n this._state = value;\n\n // Only emit if state changed to a non-null value\n if (value !== null && !Consent.isConsentStateEqual(previousState, value)) {\n this.emit(ConsentEvent.ConsentChanged, value);\n }\n }\n\n /**\n * Whether consent mode is active.\n * Returns true when state has been set.\n */\n get isActive(): boolean {\n return this._state !== null;\n }\n\n private constructor() {\n super();\n }\n\n /**\n * Compare two consent states for equality.\n *\n * @param a - First consent state (or null)\n * @param b - Second consent state (or null)\n * @returns Whether the states are equal\n */\n private static isConsentStateEqual<T extends string = string>(\n a: ConsentState<T> | null,\n b: ConsentState<T> | null,\n ): boolean {\n if (a === null && b === null) return true;\n if (a === null || b === null) return false;\n\n const keysA = Object.keys(a);\n const keysB = Object.keys(b);\n\n if (keysA.length !== keysB.length) return false;\n\n const aRecord = a as Record<string, boolean | undefined>;\n const bRecord = b as Record<string, boolean | undefined>;\n\n return keysA.every((key) => aRecord[key] === bRecord[key]);\n }\n\n /**\n * Get the singleton instance of the Consent class.\n *\n * @returns The Consent singleton instance.\n */\n public static getInstance(): Consent {\n if (!Consent.instance) {\n Consent.instance = new Consent();\n }\n\n return Consent.instance;\n }\n}\n","/**\n * @license\n * @monterosa/sdk-consent-kit\n *\n * Copyright © 2026 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { Unsubscribe, MonterosaError } from '@monterosa/sdk-util';\nimport { getParentApplication } from '@monterosa/sdk-launcher-kit';\n\nimport {\n ConsentState,\n ConsentKit,\n ConsentEvent,\n ConsentError,\n ConsentErrorMessages,\n ConsentHook,\n} from './types';\n\nimport { Consent } from './consent';\n\nconst consentHooks: ConsentHook[] = [];\nlet hooksRegistered = false;\n\n/**\n * Get the consent kit instance.\n *\n * @returns The consent kit instance.\n *\n * @internal\n */\nexport function getConsent(): ConsentKit {\n const consent = Consent.getInstance();\n\n if (!hooksRegistered) {\n // Register hooks only once\n for (const hook of consentHooks) {\n hook(consent);\n }\n\n hooksRegistered = true;\n }\n\n return consent;\n}\n\n/**\n * Register a hook that will be called when consent is initialized.\n *\n * @param hook - The hook function to register.\n *\n * @internal\n */\nexport function registerConsentHook(hook: ConsentHook): void {\n consentHooks.push(hook);\n}\n\n/**\n * Set the consent state.\n *\n * @remarks\n * - The 'necessary' category cannot be set to false\n * - Cannot be called from a child experience (use parent application instead)\n *\n * @example\n * ```typescript\n * setConsentState({\n * necessary: true,\n * analytics: true,\n * marketing: false,\n * functional: true,\n * });\n * ```\n *\n * @param state - The consent state to set\n * @throws {MonterosaError} If called from a child experience\n * @throws {MonterosaError} If 'necessary' category is set to false\n */\nexport function setConsentState<T extends string = string>(\n state: ConsentState<T>,\n): void {\n const parentApp = getParentApplication();\n\n // Cannot set consent from a child experience\n if (parentApp !== null) {\n throw new MonterosaError(\n ConsentError.CannotSetFromChild,\n ConsentErrorMessages[ConsentError.CannotSetFromChild](),\n );\n }\n\n // Necessary category cannot be false\n if ('necessary' in state && state.necessary === false) {\n throw new MonterosaError(\n ConsentError.NecessaryCategoryRequired,\n ConsentErrorMessages[ConsentError.NecessaryCategoryRequired](),\n );\n }\n\n const consent = getConsent();\n consent.state = state;\n}\n\n/**\n * Get the current consent state.\n *\n * @example\n * ```typescript\n * const state = getConsentState();\n * if (state.analytics) {\n * // Analytics consent granted\n * }\n * ```\n *\n * @returns The current consent state, or empty object if consent mode not active\n */\nexport function getConsentState<T extends string = string>(): ConsentState<T> {\n return (getConsent().state ?? {}) as ConsentState<T>;\n}\n\n/**\n * Check if consent is granted for a specific category.\n *\n * @remarks\n * - The 'necessary' category always returns true\n * - Returns true if consent mode is not active (backwards compatibility)\n * - Returns false for missing keys when consent mode is active (GDPR strict opt-in)\n * - Returns the boolean value if the category exists in consent state\n *\n * @example\n * ```typescript\n * if (hasConsent('analytics')) {\n * // Track analytics event\n * }\n * ```\n *\n * @param category - The consent category to check\n * @returns Whether consent is granted for the category\n */\nexport function hasConsent(category: string): boolean {\n // 'necessary' always returns true\n if (category === 'necessary') {\n return true;\n }\n\n const consent = getConsent();\n\n // If consent mode not active, allow everything (backwards compatibility)\n if (!consent.isActive) {\n return true;\n }\n\n // GDPR strict opt-in: missing keys default to false\n return (\n (consent.state as Record<string, boolean | undefined>)?.[category] === true\n );\n}\n\n/**\n * Subscribe to consent state changes.\n *\n * @example\n * ```typescript\n * const unsubscribe = onConsentChanged((state) => {\n * console.log('Consent changed:', state);\n * });\n *\n * // Later, to stop listening:\n * unsubscribe();\n * ```\n *\n * @param callback - The callback to call when consent state changes\n * @returns A function to unsubscribe from the event\n */\nexport function onConsentChanged<T extends string = string>(\n callback: (state: ConsentState<T>) => void,\n): Unsubscribe {\n const consent = getConsent();\n\n return consent.on(ConsentEvent.ConsentChanged, callback);\n}\n\n/**\n * Update consent state from parent (used internally by bridge).\n *\n * @param state - The consent state received from parent\n *\n * @internal\n */\nexport function updateConsentFromParent<T extends string = string>(\n state: ConsentState<T>,\n): void {\n const consent = getConsent();\n consent.state = state;\n}\n","/**\n * @license\n * @monterosa/sdk-consent-kit\n *\n * Copyright © 2026 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { Unsubscribe } from '@monterosa/sdk-util';\nimport {\n Experience,\n Message,\n getParentApplication,\n onSdkMessage,\n sendSdkMessage,\n} from '@monterosa/sdk-launcher-kit';\n\nimport { ConsentKit, ConsentState, ConsentAction } from './types';\n\nimport { getConsent, onConsentChanged, updateConsentFromParent } from './api';\n\nconst experienceUnsubs = new Map<string, Unsubscribe[]>();\n\n/**\n * Handle when an experience is embedded.\n * Sends current consent state to the child (queued by the bridge until\n * the experience is initialised) and subscribes to consent changes.\n *\n * @param experience - The embedded experience\n *\n * @internal\n */\nexport function handleExperienceEmbedded(experience: Experience): void {\n const consent = getConsent();\n\n // Send current consent state if active.\n // The bridge queues this message until the experience is initialised.\n if (consent.isActive) {\n sendSdkMessage(experience, ConsentAction.OnConsentUpdated, {\n state: consent.state,\n });\n }\n\n // Subscribe to consent changes and push to child\n const consentChangedUnsub = onConsentChanged((state) => {\n sendSdkMessage(experience, ConsentAction.OnConsentUpdated, {\n state,\n });\n });\n\n experienceUnsubs.set(experience.id, [consentChangedUnsub]);\n}\n\n/**\n * Handle when an experience is unmounted.\n * Cleans up subscriptions for the experience.\n *\n * @param experience - The unmounted experience\n *\n * @internal\n */\nexport function handleExperienceUnmounted(experience: Experience): void {\n const unsubs = experienceUnsubs.get(experience.id);\n\n if (unsubs) {\n for (const unsub of unsubs) {\n unsub();\n }\n\n experienceUnsubs.delete(experience.id);\n }\n}\n\n/**\n * Hook to listen for consent messages from parent application.\n * This is called when consent-kit is initialized in a child experience.\n *\n * @param consent - The consent kit instance\n * @returns Unsubscribe function\n *\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport function parentMessagesHook(consent: ConsentKit): Unsubscribe {\n const parentApp = getParentApplication();\n\n if (parentApp === null) {\n return () => {};\n }\n\n return onSdkMessage(parentApp, (message: Message) => {\n if (message.action === ConsentAction.OnConsentUpdated) {\n const { state } = message.payload as { state: ConsentState };\n\n updateConsentFromParent(state);\n }\n });\n}\n","/**\n * @license\n * @monterosa/sdk-consent-kit\n *\n * Copyright © 2026 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\n/**\n * Monterosa SDK / Consent Kit\n *\n * @packageDocumentation\n */\n\nimport { onStateChanged } from '@monterosa/sdk-launcher-kit';\n\nimport {\n handleExperienceEmbedded,\n handleExperienceUnmounted,\n parentMessagesHook,\n} from './bridge';\n\nimport { registerConsentHook } from './api';\n\n// Register bridge handlers for parent-child communication\nonStateChanged((experience, state) => {\n if (state === 'mounted') {\n handleExperienceEmbedded(experience);\n } else if (state === 'unmounted') {\n handleExperienceUnmounted(experience);\n }\n});\n\n// Register hook for child experiences to receive consent from parent\nregisterConsentHook(parentMessagesHook);\n\n// Public API exports\nexport {\n setConsentState,\n getConsentState,\n hasConsent,\n onConsentChanged,\n} from './api';\n\n// Type exports\nexport { DefaultCategory, ConsentState, ConsentError } from './types';\n"],"names":["ConsentError","Emitter","getParentApplication","MonterosaError","sendSdkMessage","onSdkMessage","onStateChanged"],"mappings":";;;;;;;AAAA;;;;;;;AAOG;;AAuCH;;;;AAIG;AACH,IAAY,aASX,CAAA;AATD,CAAA,UAAY,aAAa,EAAA;AACvB;;AAEG;AACH,IAAA,aAAA,CAAA,kBAAA,CAAA,GAAA,yBAA4C,CAAA;AAC5C;;AAEG;AACH,IAAA,aAAA,CAAA,YAAA,CAAA,GAAA,mBAAgC,CAAA;AAClC,CAAC,EATW,aAAa,KAAb,aAAa,GASxB,EAAA,CAAA,CAAA,CAAA;AAED;;;;AAIG;AACH,IAAY,YAKX,CAAA;AALD,CAAA,UAAY,YAAY,EAAA;AACtB;;AAEG;AACH,IAAA,YAAA,CAAA,gBAAA,CAAA,GAAA,iBAAkC,CAAA;AACpC,CAAC,EALW,YAAY,KAAZ,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AoB,EAAE,CAAC;IAEzC,IAAI,SAAS,KAAK,IAAI,EAAE;QACtB,OAAO,YAAA,GAAQ,CAAC;AACjB,KAAA;AAED,IAAA,OAAOG,2BAAY,CAAC,SAAS,EAAE,UAAC,OAAgB,EAAA;AAC9C,QAAA,IAAI,OAAO,CAAC,MAAM,KAAK,aAAa,CAAC,gBAAgB,EAAE;AAC7C,YAAA,IAAA,KAAK,GAAK,OAAO,CAAC,OAAkC,MAA/C,CAAgD;YAE7D,uBAAuB,CAAC,KAAK,CAAC,CAAC;AAChC,SAAA;AACH,KAAC,CAAC,CAAC;AACL;;AClGA;;;;;;;AAOG;AAkBH;AACAC,6BAAc,CAAC,UAAC,UAAU,EAAE,KAAK,EAAA;IAC/B,IAAI,KAAK,KAAK,SAAS,EAAE;QACvB,wBAAwB,CAAC,UAAU,CAAC,CAAC;AACtC,KAAA;SAAM,IAAI,KAAK,KAAK,WAAW,EAAE;QAChC,yBAAyB,CAAC,UAAU,CAAC,CAAC;AACvC,KAAA;AACH,CAAC,CAAC,CAAC;AAEH;AACA,mBAAmB,CAAC,kBAAkB,CAAC;;;;;;;"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @license
3
+ * @monterosa/sdk-consent-kit
4
+ *
5
+ * Copyright © 2026 Monterosa Productions Limited. All rights reserved.
6
+ *
7
+ * More details on the license can be found at https://www.monterosa.co/sdk/license
8
+ */
9
+ export { setConsentState, getConsentState, hasConsent, onConsentChanged, } from './api';
10
+ export { DefaultCategory, ConsentState, ConsentError } from './types';
@@ -0,0 +1,399 @@
1
+ import { getParentApplication, sendSdkMessage, onSdkMessage, onStateChanged } from '@monterosa/sdk-launcher-kit';
2
+ import { Emitter, MonterosaError } from '@monterosa/sdk-util';
3
+
4
+ /**
5
+ * @license
6
+ * @monterosa/sdk-consent-kit
7
+ *
8
+ * Copyright © 2026 Monterosa Productions Limited. All rights reserved.
9
+ *
10
+ * More details on the license can be found at https://www.monterosa.co/sdk/license
11
+ */
12
+ /**
13
+ * Actions used for parent-child bridge communication.
14
+ *
15
+ * @internal
16
+ */
17
+ var ConsentAction;
18
+ (function (ConsentAction) {
19
+ /**
20
+ * Sent when consent state is updated.
21
+ */
22
+ ConsentAction["OnConsentUpdated"] = "consentOnConsentUpdated";
23
+ /**
24
+ * Request to set consent state from child to parent.
25
+ */
26
+ ConsentAction["SetConsent"] = "consentSetConsent";
27
+ })(ConsentAction || (ConsentAction = {}));
28
+ /**
29
+ * Internal event names for the consent emitter.
30
+ *
31
+ * @internal
32
+ */
33
+ var ConsentEvent;
34
+ (function (ConsentEvent) {
35
+ /**
36
+ * Emitted when consent state changes.
37
+ */
38
+ ConsentEvent["ConsentChanged"] = "consent_changed";
39
+ })(ConsentEvent || (ConsentEvent = {}));
40
+ /**
41
+ * Defines error codes that may be encountered when using the Consent kit.
42
+ *
43
+ * @example
44
+ * ```typescript
45
+ * try {
46
+ * setConsentState({ necessary: false });
47
+ * } catch (err) {
48
+ * if (err.code === ConsentError.NecessaryCategoryRequired) {
49
+ * // handle necessary category error
50
+ * }
51
+ * }
52
+ * ```
53
+ */
54
+ var ConsentError;
55
+ (function (ConsentError) {
56
+ /**
57
+ * Indicates that the 'necessary' category cannot be set to false.
58
+ */
59
+ ConsentError["NecessaryCategoryRequired"] = "necessary_category_required";
60
+ /**
61
+ * Indicates that consent cannot be set from a child experience.
62
+ */
63
+ ConsentError["CannotSetFromChild"] = "cannot_set_from_child";
64
+ })(ConsentError || (ConsentError = {}));
65
+ /**
66
+ * Error messages for consent errors.
67
+ *
68
+ * @internal
69
+ */
70
+ const ConsentErrorMessages = {
71
+ [ConsentError.NecessaryCategoryRequired]: () => "Cannot set 'necessary' category to false. Strictly necessary functionality cannot be disabled.",
72
+ [ConsentError.CannotSetFromChild]: () => 'Cannot set consent state from embedded experience. Consent is managed by the parent application.',
73
+ };
74
+
75
+ /**
76
+ * @license
77
+ * @monterosa/sdk-consent-kit
78
+ *
79
+ * Copyright © 2026 Monterosa Productions Limited. All rights reserved.
80
+ *
81
+ * More details on the license can be found at https://www.monterosa.co/sdk/license
82
+ */
83
+ /**
84
+ * Internal Consent class that manages consent state.
85
+ *
86
+ * @internal
87
+ */
88
+ class Consent extends Emitter {
89
+ /**
90
+ * The current consent state.
91
+ * Setting this value will automatically emit ConsentChanged event if the state
92
+ * actually changed.
93
+ */
94
+ get state() {
95
+ return this._state;
96
+ }
97
+ set state(value) {
98
+ const previousState = this._state;
99
+ this._state = value;
100
+ // Only emit if state changed to a non-null value
101
+ if (value !== null && !Consent.isConsentStateEqual(previousState, value)) {
102
+ this.emit(ConsentEvent.ConsentChanged, value);
103
+ }
104
+ }
105
+ /**
106
+ * Whether consent mode is active.
107
+ * Returns true when state has been set.
108
+ */
109
+ get isActive() {
110
+ return this._state !== null;
111
+ }
112
+ constructor() {
113
+ super();
114
+ this._state = null;
115
+ }
116
+ /**
117
+ * Compare two consent states for equality.
118
+ *
119
+ * @param a - First consent state (or null)
120
+ * @param b - Second consent state (or null)
121
+ * @returns Whether the states are equal
122
+ */
123
+ static isConsentStateEqual(a, b) {
124
+ if (a === null && b === null)
125
+ return true;
126
+ if (a === null || b === null)
127
+ return false;
128
+ const keysA = Object.keys(a);
129
+ const keysB = Object.keys(b);
130
+ if (keysA.length !== keysB.length)
131
+ return false;
132
+ const aRecord = a;
133
+ const bRecord = b;
134
+ return keysA.every((key) => aRecord[key] === bRecord[key]);
135
+ }
136
+ /**
137
+ * Get the singleton instance of the Consent class.
138
+ *
139
+ * @returns The Consent singleton instance.
140
+ */
141
+ static getInstance() {
142
+ if (!Consent.instance) {
143
+ Consent.instance = new Consent();
144
+ }
145
+ return Consent.instance;
146
+ }
147
+ }
148
+
149
+ /**
150
+ * @license
151
+ * @monterosa/sdk-consent-kit
152
+ *
153
+ * Copyright © 2026 Monterosa Productions Limited. All rights reserved.
154
+ *
155
+ * More details on the license can be found at https://www.monterosa.co/sdk/license
156
+ */
157
+ const consentHooks = [];
158
+ let hooksRegistered = false;
159
+ /**
160
+ * Get the consent kit instance.
161
+ *
162
+ * @returns The consent kit instance.
163
+ *
164
+ * @internal
165
+ */
166
+ function getConsent() {
167
+ const consent = Consent.getInstance();
168
+ if (!hooksRegistered) {
169
+ // Register hooks only once
170
+ for (const hook of consentHooks) {
171
+ hook(consent);
172
+ }
173
+ hooksRegistered = true;
174
+ }
175
+ return consent;
176
+ }
177
+ /**
178
+ * Register a hook that will be called when consent is initialized.
179
+ *
180
+ * @param hook - The hook function to register.
181
+ *
182
+ * @internal
183
+ */
184
+ function registerConsentHook(hook) {
185
+ consentHooks.push(hook);
186
+ }
187
+ /**
188
+ * Set the consent state.
189
+ *
190
+ * @remarks
191
+ * - The 'necessary' category cannot be set to false
192
+ * - Cannot be called from a child experience (use parent application instead)
193
+ *
194
+ * @example
195
+ * ```typescript
196
+ * setConsentState({
197
+ * necessary: true,
198
+ * analytics: true,
199
+ * marketing: false,
200
+ * functional: true,
201
+ * });
202
+ * ```
203
+ *
204
+ * @param state - The consent state to set
205
+ * @throws {MonterosaError} If called from a child experience
206
+ * @throws {MonterosaError} If 'necessary' category is set to false
207
+ */
208
+ function setConsentState(state) {
209
+ const parentApp = getParentApplication();
210
+ // Cannot set consent from a child experience
211
+ if (parentApp !== null) {
212
+ throw new MonterosaError(ConsentError.CannotSetFromChild, ConsentErrorMessages[ConsentError.CannotSetFromChild]());
213
+ }
214
+ // Necessary category cannot be false
215
+ if ('necessary' in state && state.necessary === false) {
216
+ throw new MonterosaError(ConsentError.NecessaryCategoryRequired, ConsentErrorMessages[ConsentError.NecessaryCategoryRequired]());
217
+ }
218
+ const consent = getConsent();
219
+ consent.state = state;
220
+ }
221
+ /**
222
+ * Get the current consent state.
223
+ *
224
+ * @example
225
+ * ```typescript
226
+ * const state = getConsentState();
227
+ * if (state.analytics) {
228
+ * // Analytics consent granted
229
+ * }
230
+ * ```
231
+ *
232
+ * @returns The current consent state, or empty object if consent mode not active
233
+ */
234
+ function getConsentState() {
235
+ var _a;
236
+ return ((_a = getConsent().state) !== null && _a !== void 0 ? _a : {});
237
+ }
238
+ /**
239
+ * Check if consent is granted for a specific category.
240
+ *
241
+ * @remarks
242
+ * - The 'necessary' category always returns true
243
+ * - Returns true if consent mode is not active (backwards compatibility)
244
+ * - Returns false for missing keys when consent mode is active (GDPR strict opt-in)
245
+ * - Returns the boolean value if the category exists in consent state
246
+ *
247
+ * @example
248
+ * ```typescript
249
+ * if (hasConsent('analytics')) {
250
+ * // Track analytics event
251
+ * }
252
+ * ```
253
+ *
254
+ * @param category - The consent category to check
255
+ * @returns Whether consent is granted for the category
256
+ */
257
+ function hasConsent(category) {
258
+ var _a;
259
+ // 'necessary' always returns true
260
+ if (category === 'necessary') {
261
+ return true;
262
+ }
263
+ const consent = getConsent();
264
+ // If consent mode not active, allow everything (backwards compatibility)
265
+ if (!consent.isActive) {
266
+ return true;
267
+ }
268
+ // GDPR strict opt-in: missing keys default to false
269
+ return (((_a = consent.state) === null || _a === void 0 ? void 0 : _a[category]) === true);
270
+ }
271
+ /**
272
+ * Subscribe to consent state changes.
273
+ *
274
+ * @example
275
+ * ```typescript
276
+ * const unsubscribe = onConsentChanged((state) => {
277
+ * console.log('Consent changed:', state);
278
+ * });
279
+ *
280
+ * // Later, to stop listening:
281
+ * unsubscribe();
282
+ * ```
283
+ *
284
+ * @param callback - The callback to call when consent state changes
285
+ * @returns A function to unsubscribe from the event
286
+ */
287
+ function onConsentChanged(callback) {
288
+ const consent = getConsent();
289
+ return consent.on(ConsentEvent.ConsentChanged, callback);
290
+ }
291
+ /**
292
+ * Update consent state from parent (used internally by bridge).
293
+ *
294
+ * @param state - The consent state received from parent
295
+ *
296
+ * @internal
297
+ */
298
+ function updateConsentFromParent(state) {
299
+ const consent = getConsent();
300
+ consent.state = state;
301
+ }
302
+
303
+ /**
304
+ * @license
305
+ * @monterosa/sdk-consent-kit
306
+ *
307
+ * Copyright © 2026 Monterosa Productions Limited. All rights reserved.
308
+ *
309
+ * More details on the license can be found at https://www.monterosa.co/sdk/license
310
+ */
311
+ const experienceUnsubs = new Map();
312
+ /**
313
+ * Handle when an experience is embedded.
314
+ * Sends current consent state to the child (queued by the bridge until
315
+ * the experience is initialised) and subscribes to consent changes.
316
+ *
317
+ * @param experience - The embedded experience
318
+ *
319
+ * @internal
320
+ */
321
+ function handleExperienceEmbedded(experience) {
322
+ const consent = getConsent();
323
+ // Send current consent state if active.
324
+ // The bridge queues this message until the experience is initialised.
325
+ if (consent.isActive) {
326
+ sendSdkMessage(experience, ConsentAction.OnConsentUpdated, {
327
+ state: consent.state,
328
+ });
329
+ }
330
+ // Subscribe to consent changes and push to child
331
+ const consentChangedUnsub = onConsentChanged((state) => {
332
+ sendSdkMessage(experience, ConsentAction.OnConsentUpdated, {
333
+ state,
334
+ });
335
+ });
336
+ experienceUnsubs.set(experience.id, [consentChangedUnsub]);
337
+ }
338
+ /**
339
+ * Handle when an experience is unmounted.
340
+ * Cleans up subscriptions for the experience.
341
+ *
342
+ * @param experience - The unmounted experience
343
+ *
344
+ * @internal
345
+ */
346
+ function handleExperienceUnmounted(experience) {
347
+ const unsubs = experienceUnsubs.get(experience.id);
348
+ if (unsubs) {
349
+ for (const unsub of unsubs) {
350
+ unsub();
351
+ }
352
+ experienceUnsubs.delete(experience.id);
353
+ }
354
+ }
355
+ /**
356
+ * Hook to listen for consent messages from parent application.
357
+ * This is called when consent-kit is initialized in a child experience.
358
+ *
359
+ * @param consent - The consent kit instance
360
+ * @returns Unsubscribe function
361
+ *
362
+ * @internal
363
+ */
364
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
365
+ function parentMessagesHook(consent) {
366
+ const parentApp = getParentApplication();
367
+ if (parentApp === null) {
368
+ return () => { };
369
+ }
370
+ return onSdkMessage(parentApp, (message) => {
371
+ if (message.action === ConsentAction.OnConsentUpdated) {
372
+ const { state } = message.payload;
373
+ updateConsentFromParent(state);
374
+ }
375
+ });
376
+ }
377
+
378
+ /**
379
+ * @license
380
+ * @monterosa/sdk-consent-kit
381
+ *
382
+ * Copyright © 2026 Monterosa Productions Limited. All rights reserved.
383
+ *
384
+ * More details on the license can be found at https://www.monterosa.co/sdk/license
385
+ */
386
+ // Register bridge handlers for parent-child communication
387
+ onStateChanged((experience, state) => {
388
+ if (state === 'mounted') {
389
+ handleExperienceEmbedded(experience);
390
+ }
391
+ else if (state === 'unmounted') {
392
+ handleExperienceUnmounted(experience);
393
+ }
394
+ });
395
+ // Register hook for child experiences to receive consent from parent
396
+ registerConsentHook(parentMessagesHook);
397
+
398
+ export { ConsentError, getConsentState, hasConsent, onConsentChanged, setConsentState };
399
+ //# sourceMappingURL=index.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.esm.js","sources":["../src/types.ts","../src/consent.ts","../src/api.ts","../src/bridge.ts","../src/index.ts"],"sourcesContent":["/**\n * @license\n * @monterosa/sdk-consent-kit\n *\n * Copyright © 2026 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { Emitter, Unsubscribe } from '@monterosa/sdk-util';\n\n/**\n * Default consent categories commonly used for GDPR/privacy compliance.\n *\n * @remarks\n * - `necessary` - Essential cookies/tracking required for the site to function\n * - `analytics` - Analytics and performance tracking\n * - `marketing` - Marketing and advertising tracking\n * - `functional` - User preference and personalization tracking\n */\nexport type DefaultCategory =\n | 'necessary'\n | 'analytics'\n | 'marketing'\n | 'functional';\n\n/**\n * Represents the consent state for each category.\n * Maps category names to boolean values indicating whether consent is granted.\n *\n * @typeParam T - The type of category keys, defaults to DefaultCategory\n *\n * @example\n * ```typescript\n * const state: ConsentState = {\n * necessary: true,\n * analytics: false,\n * marketing: false,\n * preferences: true,\n * };\n * ```\n */\nexport type ConsentState<T extends string = DefaultCategory> = {\n [K in T]?: boolean;\n};\n\n/**\n * Actions used for parent-child bridge communication.\n *\n * @internal\n */\nexport enum ConsentAction {\n /**\n * Sent when consent state is updated.\n */\n OnConsentUpdated = 'consentOnConsentUpdated',\n /**\n * Request to set consent state from child to parent.\n */\n SetConsent = 'consentSetConsent',\n}\n\n/**\n * Internal event names for the consent emitter.\n *\n * @internal\n */\nexport enum ConsentEvent {\n /**\n * Emitted when consent state changes.\n */\n ConsentChanged = 'consent_changed',\n}\n\n/**\n * Defines error codes that may be encountered when using the Consent kit.\n *\n * @example\n * ```typescript\n * try {\n * setConsentState({ necessary: false });\n * } catch (err) {\n * if (err.code === ConsentError.NecessaryCategoryRequired) {\n * // handle necessary category error\n * }\n * }\n * ```\n */\nexport enum ConsentError {\n /**\n * Indicates that the 'necessary' category cannot be set to false.\n */\n NecessaryCategoryRequired = 'necessary_category_required',\n /**\n * Indicates that consent cannot be set from a child experience.\n */\n CannotSetFromChild = 'cannot_set_from_child',\n}\n\n/**\n * Error messages for consent errors.\n *\n * @internal\n */\nexport const ConsentErrorMessages = {\n [ConsentError.NecessaryCategoryRequired]: () =>\n \"Cannot set 'necessary' category to false. Strictly necessary functionality cannot be disabled.\",\n [ConsentError.CannotSetFromChild]: () =>\n 'Cannot set consent state from embedded experience. Consent is managed by the parent application.',\n};\n\n/**\n * Hook function type for registering consent hooks.\n *\n * @internal\n */\nexport type ConsentHook = (consent: ConsentKit) => Unsubscribe;\n\n/**\n * The ConsentKit interface provides properties and methods\n * for managing user consent state.\n *\n * @internal\n */\nexport interface ConsentKit extends Emitter {\n /**\n * Whether consent mode is active.\n * Returns true when state has been set.\n */\n readonly isActive: boolean;\n /**\n * The current consent state.\n */\n state: ConsentState | null;\n}\n","/**\n * @license\n * @monterosa/sdk-consent-kit\n *\n * Copyright © 2026 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { Emitter } from '@monterosa/sdk-util';\n\nimport { ConsentKit, ConsentState, ConsentEvent } from './types';\n\n/**\n * Internal Consent class that manages consent state.\n *\n * @internal\n */\nexport class Consent extends Emitter implements ConsentKit {\n private static instance: Consent;\n\n private _state: ConsentState | null = null;\n\n /**\n * The current consent state.\n * Setting this value will automatically emit ConsentChanged event if the state\n * actually changed.\n */\n get state(): ConsentState | null {\n return this._state;\n }\n\n set state(value: ConsentState | null) {\n const previousState = this._state;\n this._state = value;\n\n // Only emit if state changed to a non-null value\n if (value !== null && !Consent.isConsentStateEqual(previousState, value)) {\n this.emit(ConsentEvent.ConsentChanged, value);\n }\n }\n\n /**\n * Whether consent mode is active.\n * Returns true when state has been set.\n */\n get isActive(): boolean {\n return this._state !== null;\n }\n\n private constructor() {\n super();\n }\n\n /**\n * Compare two consent states for equality.\n *\n * @param a - First consent state (or null)\n * @param b - Second consent state (or null)\n * @returns Whether the states are equal\n */\n private static isConsentStateEqual<T extends string = string>(\n a: ConsentState<T> | null,\n b: ConsentState<T> | null,\n ): boolean {\n if (a === null && b === null) return true;\n if (a === null || b === null) return false;\n\n const keysA = Object.keys(a);\n const keysB = Object.keys(b);\n\n if (keysA.length !== keysB.length) return false;\n\n const aRecord = a as Record<string, boolean | undefined>;\n const bRecord = b as Record<string, boolean | undefined>;\n\n return keysA.every((key) => aRecord[key] === bRecord[key]);\n }\n\n /**\n * Get the singleton instance of the Consent class.\n *\n * @returns The Consent singleton instance.\n */\n public static getInstance(): Consent {\n if (!Consent.instance) {\n Consent.instance = new Consent();\n }\n\n return Consent.instance;\n }\n}\n","/**\n * @license\n * @monterosa/sdk-consent-kit\n *\n * Copyright © 2026 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { Unsubscribe, MonterosaError } from '@monterosa/sdk-util';\nimport { getParentApplication } from '@monterosa/sdk-launcher-kit';\n\nimport {\n ConsentState,\n ConsentKit,\n ConsentEvent,\n ConsentError,\n ConsentErrorMessages,\n ConsentHook,\n} from './types';\n\nimport { Consent } from './consent';\n\nconst consentHooks: ConsentHook[] = [];\nlet hooksRegistered = false;\n\n/**\n * Get the consent kit instance.\n *\n * @returns The consent kit instance.\n *\n * @internal\n */\nexport function getConsent(): ConsentKit {\n const consent = Consent.getInstance();\n\n if (!hooksRegistered) {\n // Register hooks only once\n for (const hook of consentHooks) {\n hook(consent);\n }\n\n hooksRegistered = true;\n }\n\n return consent;\n}\n\n/**\n * Register a hook that will be called when consent is initialized.\n *\n * @param hook - The hook function to register.\n *\n * @internal\n */\nexport function registerConsentHook(hook: ConsentHook): void {\n consentHooks.push(hook);\n}\n\n/**\n * Set the consent state.\n *\n * @remarks\n * - The 'necessary' category cannot be set to false\n * - Cannot be called from a child experience (use parent application instead)\n *\n * @example\n * ```typescript\n * setConsentState({\n * necessary: true,\n * analytics: true,\n * marketing: false,\n * functional: true,\n * });\n * ```\n *\n * @param state - The consent state to set\n * @throws {MonterosaError} If called from a child experience\n * @throws {MonterosaError} If 'necessary' category is set to false\n */\nexport function setConsentState<T extends string = string>(\n state: ConsentState<T>,\n): void {\n const parentApp = getParentApplication();\n\n // Cannot set consent from a child experience\n if (parentApp !== null) {\n throw new MonterosaError(\n ConsentError.CannotSetFromChild,\n ConsentErrorMessages[ConsentError.CannotSetFromChild](),\n );\n }\n\n // Necessary category cannot be false\n if ('necessary' in state && state.necessary === false) {\n throw new MonterosaError(\n ConsentError.NecessaryCategoryRequired,\n ConsentErrorMessages[ConsentError.NecessaryCategoryRequired](),\n );\n }\n\n const consent = getConsent();\n consent.state = state;\n}\n\n/**\n * Get the current consent state.\n *\n * @example\n * ```typescript\n * const state = getConsentState();\n * if (state.analytics) {\n * // Analytics consent granted\n * }\n * ```\n *\n * @returns The current consent state, or empty object if consent mode not active\n */\nexport function getConsentState<T extends string = string>(): ConsentState<T> {\n return (getConsent().state ?? {}) as ConsentState<T>;\n}\n\n/**\n * Check if consent is granted for a specific category.\n *\n * @remarks\n * - The 'necessary' category always returns true\n * - Returns true if consent mode is not active (backwards compatibility)\n * - Returns false for missing keys when consent mode is active (GDPR strict opt-in)\n * - Returns the boolean value if the category exists in consent state\n *\n * @example\n * ```typescript\n * if (hasConsent('analytics')) {\n * // Track analytics event\n * }\n * ```\n *\n * @param category - The consent category to check\n * @returns Whether consent is granted for the category\n */\nexport function hasConsent(category: string): boolean {\n // 'necessary' always returns true\n if (category === 'necessary') {\n return true;\n }\n\n const consent = getConsent();\n\n // If consent mode not active, allow everything (backwards compatibility)\n if (!consent.isActive) {\n return true;\n }\n\n // GDPR strict opt-in: missing keys default to false\n return (\n (consent.state as Record<string, boolean | undefined>)?.[category] === true\n );\n}\n\n/**\n * Subscribe to consent state changes.\n *\n * @example\n * ```typescript\n * const unsubscribe = onConsentChanged((state) => {\n * console.log('Consent changed:', state);\n * });\n *\n * // Later, to stop listening:\n * unsubscribe();\n * ```\n *\n * @param callback - The callback to call when consent state changes\n * @returns A function to unsubscribe from the event\n */\nexport function onConsentChanged<T extends string = string>(\n callback: (state: ConsentState<T>) => void,\n): Unsubscribe {\n const consent = getConsent();\n\n return consent.on(ConsentEvent.ConsentChanged, callback);\n}\n\n/**\n * Update consent state from parent (used internally by bridge).\n *\n * @param state - The consent state received from parent\n *\n * @internal\n */\nexport function updateConsentFromParent<T extends string = string>(\n state: ConsentState<T>,\n): void {\n const consent = getConsent();\n consent.state = state;\n}\n","/**\n * @license\n * @monterosa/sdk-consent-kit\n *\n * Copyright © 2026 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { Unsubscribe } from '@monterosa/sdk-util';\nimport {\n Experience,\n Message,\n getParentApplication,\n onSdkMessage,\n sendSdkMessage,\n} from '@monterosa/sdk-launcher-kit';\n\nimport { ConsentKit, ConsentState, ConsentAction } from './types';\n\nimport { getConsent, onConsentChanged, updateConsentFromParent } from './api';\n\nconst experienceUnsubs = new Map<string, Unsubscribe[]>();\n\n/**\n * Handle when an experience is embedded.\n * Sends current consent state to the child (queued by the bridge until\n * the experience is initialised) and subscribes to consent changes.\n *\n * @param experience - The embedded experience\n *\n * @internal\n */\nexport function handleExperienceEmbedded(experience: Experience): void {\n const consent = getConsent();\n\n // Send current consent state if active.\n // The bridge queues this message until the experience is initialised.\n if (consent.isActive) {\n sendSdkMessage(experience, ConsentAction.OnConsentUpdated, {\n state: consent.state,\n });\n }\n\n // Subscribe to consent changes and push to child\n const consentChangedUnsub = onConsentChanged((state) => {\n sendSdkMessage(experience, ConsentAction.OnConsentUpdated, {\n state,\n });\n });\n\n experienceUnsubs.set(experience.id, [consentChangedUnsub]);\n}\n\n/**\n * Handle when an experience is unmounted.\n * Cleans up subscriptions for the experience.\n *\n * @param experience - The unmounted experience\n *\n * @internal\n */\nexport function handleExperienceUnmounted(experience: Experience): void {\n const unsubs = experienceUnsubs.get(experience.id);\n\n if (unsubs) {\n for (const unsub of unsubs) {\n unsub();\n }\n\n experienceUnsubs.delete(experience.id);\n }\n}\n\n/**\n * Hook to listen for consent messages from parent application.\n * This is called when consent-kit is initialized in a child experience.\n *\n * @param consent - The consent kit instance\n * @returns Unsubscribe function\n *\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport function parentMessagesHook(consent: ConsentKit): Unsubscribe {\n const parentApp = getParentApplication();\n\n if (parentApp === null) {\n return () => {};\n }\n\n return onSdkMessage(parentApp, (message: Message) => {\n if (message.action === ConsentAction.OnConsentUpdated) {\n const { state } = message.payload as { state: ConsentState };\n\n updateConsentFromParent(state);\n }\n });\n}\n","/**\n * @license\n * @monterosa/sdk-consent-kit\n *\n * Copyright © 2026 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\n/**\n * Monterosa SDK / Consent Kit\n *\n * @packageDocumentation\n */\n\nimport { onStateChanged } from '@monterosa/sdk-launcher-kit';\n\nimport {\n handleExperienceEmbedded,\n handleExperienceUnmounted,\n parentMessagesHook,\n} from './bridge';\n\nimport { registerConsentHook } from './api';\n\n// Register bridge handlers for parent-child communication\nonStateChanged((experience, state) => {\n if (state === 'mounted') {\n handleExperienceEmbedded(experience);\n } else if (state === 'unmounted') {\n handleExperienceUnmounted(experience);\n }\n});\n\n// Register hook for child experiences to receive consent from parent\nregisterConsentHook(parentMessagesHook);\n\n// Public API exports\nexport {\n setConsentState,\n getConsentState,\n hasConsent,\n onConsentChanged,\n} from './api';\n\n// Type exports\nexport { DefaultCategory, ConsentState, ConsentError } from './types';\n"],"names":[],"mappings":";;;AAAA;;;;;;;AAOG;AAuCH;;;;AAIG;AACH,IAAY,aASX,CAAA;AATD,CAAA,UAAY,aAAa,EAAA;AACvB;;AAEG;AACH,IAAA,aAAA,CAAA,kBAAA,CAAA,GAAA,yBAA4C,CAAA;AAC5C;;AAEG;AACH,IAAA,aAAA,CAAA,YAAA,CAAA,GAAA,mBAAgC,CAAA;AAClC,CAAC,EATW,aAAa,KAAb,aAAa,GASxB,EAAA,CAAA,CAAA,CAAA;AAED;;;;AAIG;AACH,IAAY,YAKX,CAAA;AALD,CAAA,UAAY,YAAY,EAAA;AACtB;;AAEG;AACH,IAAA,YAAA,CAAA,gBAAA,CAAA,GAAA,iBAAkC,CAAA;AACpC,CAAC,EALW,YAAY,KAAZ,YAAY,GAKvB,EAAA,CAAA,CAAA,CAAA;AAED;;;;;;;;;;;;;AAaG;IACS,aASX;AATD,CAAA,UAAY,YAAY,EAAA;AACtB;;AAEG;AACH,IAAA,YAAA,CAAA,2BAAA,CAAA,GAAA,6BAAyD,CAAA;AACzD;;AAEG;AACH,IAAA,YAAA,CAAA,oBAAA,CAAA,GAAA,uBAA4C,CAAA;AAC9C,CAAC,EATW,YAAY,KAAZ,YAAY,GASvB,EAAA,CAAA,CAAA,CAAA;AAED;;;;AAIG;AACI,MAAM,oBAAoB,GAAG;IAClC,CAAC,YAAY,CAAC,yBAAyB,GAAG,MACxC,gGAAgG;IAClG,CAAC,YAAY,CAAC,kBAAkB,GAAG,MACjC,kGAAkG;CACrG;;AC7GD;;;;;;;AAOG;AAMH;;;;AAIG;AACG,MAAO,OAAQ,SAAQ,OAAO,CAAA;AAKlC;;;;AAIG;AACH,IAAA,IAAI,KAAK,GAAA;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;KACpB;IAED,IAAI,KAAK,CAAC,KAA0B,EAA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AAE,GAAG,OAAO,CAAC,OAAkC,CAAC;YAE7D,uBAAuB,CAAC,KAAK,CAAC,CAAC;AAChC,SAAA;AACH,KAAC,CAAC,CAAC;AACL;;AClGA;;;;;;;AAOG;AAkBH;AACA,cAAc,CAAC,CAAC,UAAU,EAAE,KAAK,KAAI;IACnC,IAAI,KAAK,KAAK,SAAS,EAAE;QACvB,wBAAwB,CAAC,UAAU,CAAC,CAAC;AACtC,KAAA;SAAM,IAAI,KAAK,KAAK,WAAW,EAAE;QAChC,yBAAyB,CAAC,UAAU,CAAC,CAAC;AACvC,KAAA;AACH,CAAC,CAAC,CAAC;AAEH;AACA,mBAAmB,CAAC,kBAAkB,CAAC;;;;"}
@@ -0,0 +1,120 @@
1
+ /**
2
+ * @license
3
+ * @monterosa/sdk-consent-kit
4
+ *
5
+ * Copyright © 2026 Monterosa Productions Limited. All rights reserved.
6
+ *
7
+ * More details on the license can be found at https://www.monterosa.co/sdk/license
8
+ */
9
+ import { Emitter, Unsubscribe } from '@monterosa/sdk-util';
10
+ /**
11
+ * Default consent categories commonly used for GDPR/privacy compliance.
12
+ *
13
+ * @remarks
14
+ * - `necessary` - Essential cookies/tracking required for the site to function
15
+ * - `analytics` - Analytics and performance tracking
16
+ * - `marketing` - Marketing and advertising tracking
17
+ * - `functional` - User preference and personalization tracking
18
+ */
19
+ export type DefaultCategory = 'necessary' | 'analytics' | 'marketing' | 'functional';
20
+ /**
21
+ * Represents the consent state for each category.
22
+ * Maps category names to boolean values indicating whether consent is granted.
23
+ *
24
+ * @typeParam T - The type of category keys, defaults to DefaultCategory
25
+ *
26
+ * @example
27
+ * ```typescript
28
+ * const state: ConsentState = {
29
+ * necessary: true,
30
+ * analytics: false,
31
+ * marketing: false,
32
+ * preferences: true,
33
+ * };
34
+ * ```
35
+ */
36
+ export type ConsentState<T extends string = DefaultCategory> = {
37
+ [K in T]?: boolean;
38
+ };
39
+ /**
40
+ * Actions used for parent-child bridge communication.
41
+ *
42
+ * @internal
43
+ */
44
+ export declare enum ConsentAction {
45
+ /**
46
+ * Sent when consent state is updated.
47
+ */
48
+ OnConsentUpdated = "consentOnConsentUpdated",
49
+ /**
50
+ * Request to set consent state from child to parent.
51
+ */
52
+ SetConsent = "consentSetConsent"
53
+ }
54
+ /**
55
+ * Internal event names for the consent emitter.
56
+ *
57
+ * @internal
58
+ */
59
+ export declare enum ConsentEvent {
60
+ /**
61
+ * Emitted when consent state changes.
62
+ */
63
+ ConsentChanged = "consent_changed"
64
+ }
65
+ /**
66
+ * Defines error codes that may be encountered when using the Consent kit.
67
+ *
68
+ * @example
69
+ * ```typescript
70
+ * try {
71
+ * setConsentState({ necessary: false });
72
+ * } catch (err) {
73
+ * if (err.code === ConsentError.NecessaryCategoryRequired) {
74
+ * // handle necessary category error
75
+ * }
76
+ * }
77
+ * ```
78
+ */
79
+ export declare enum ConsentError {
80
+ /**
81
+ * Indicates that the 'necessary' category cannot be set to false.
82
+ */
83
+ NecessaryCategoryRequired = "necessary_category_required",
84
+ /**
85
+ * Indicates that consent cannot be set from a child experience.
86
+ */
87
+ CannotSetFromChild = "cannot_set_from_child"
88
+ }
89
+ /**
90
+ * Error messages for consent errors.
91
+ *
92
+ * @internal
93
+ */
94
+ export declare const ConsentErrorMessages: {
95
+ necessary_category_required: () => string;
96
+ cannot_set_from_child: () => string;
97
+ };
98
+ /**
99
+ * Hook function type for registering consent hooks.
100
+ *
101
+ * @internal
102
+ */
103
+ export type ConsentHook = (consent: ConsentKit) => Unsubscribe;
104
+ /**
105
+ * The ConsentKit interface provides properties and methods
106
+ * for managing user consent state.
107
+ *
108
+ * @internal
109
+ */
110
+ export interface ConsentKit extends Emitter {
111
+ /**
112
+ * Whether consent mode is active.
113
+ * Returns true when state has been set.
114
+ */
115
+ readonly isActive: boolean;
116
+ /**
117
+ * The current consent state.
118
+ */
119
+ state: ConsentState | null;
120
+ }
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@monterosa/sdk-consent-kit",
3
+ "version": "2.0.0-rc.1",
4
+ "description": "Consent Kit for the Monterosa JS SDK",
5
+ "author": "Monterosa Productions Limited <hello@monterosa.co.uk> (https://www.monterosa.co/)",
6
+ "main": "dist/index.cjs.js",
7
+ "browser": "dist/index.esm.js",
8
+ "module": "dist/index.esm.js",
9
+ "types": "./dist/index.d.ts",
10
+ "cdn": "../../dist",
11
+ "files": [
12
+ "dist"
13
+ ],
14
+ "scripts": {
15
+ "dev": "rollup -c -w",
16
+ "build": "rollup -c",
17
+ "test": "jest --color",
18
+ "test:watch": "jest --color --watchAll",
19
+ "test:ci": "jest --color --ci --reporters=jest-junit --coverage",
20
+ "api-report": "api-extractor run --local --verbose"
21
+ },
22
+ "keywords": [],
23
+ "license": "MIT",
24
+ "peerDependencies": {
25
+ "@monterosa/sdk-launcher-kit": "0.x",
26
+ "@monterosa/sdk-util": "0.x"
27
+ },
28
+ "dependencies": {
29
+ "@monterosa/sdk-launcher-kit": "^2.0.0-rc.1",
30
+ "@monterosa/sdk-util": "^2.0.0-rc.1"
31
+ },
32
+ "devDependencies": {
33
+ "@faker-js/faker": "^6.3.1",
34
+ "@rollup/plugin-commonjs": "^21.1.0",
35
+ "@rollup/plugin-json": "^4.1.0",
36
+ "@rollup/plugin-node-resolve": "^13.3.0",
37
+ "@rollup/plugin-terser": "^0.4.4",
38
+ "@types/jest": "29.5.3",
39
+ "jest": "29.6.1",
40
+ "jest-junit": "^13.0.0",
41
+ "rollup": "^2.57.0",
42
+ "rollup-plugin-dts": "^4.0.0",
43
+ "rollup-plugin-typescript2": "^0.36.0",
44
+ "ts-jest": "29.1.1",
45
+ "tslib": "^2.3.0",
46
+ "typescript": "4.9.5"
47
+ },
48
+ "publishConfig": {
49
+ "access": "public"
50
+ },
51
+ "gitHead": "7cb580eebfab4fb87632a96519dac2f9762fc8b2"
52
+ }