@drip-apex/sdk 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/sri.json CHANGED
@@ -1,23 +1,23 @@
1
1
  {
2
2
  "drip.js": {
3
- "sha384": "sha384-QcviG2yudwcp21+saOzRBTao3iCw9Klvg0E6tn+8WtZSj59rtG+pYDPisLayylr2",
4
- "bytes": 441764,
5
- "gzipBytes": 132087
3
+ "sha384": "sha384-ofIM5ttcdwn80cLOgeMVf0hPI+YFzkb64boUqnp45yOYmJbeGZc4ksGolmx+27So",
4
+ "bytes": 442221,
5
+ "gzipBytes": 132195
6
6
  },
7
7
  "drip.live.js": {
8
- "sha384": "sha384-SWfJun6EaNrR6EGydboVMqywr1cWkg6wn68hxAhS9qDRadAm2INiQX6+wp97p0Ih",
9
- "bytes": 343553,
10
- "gzipBytes": 102995
8
+ "sha384": "sha384-ecW1st7t1S3TN5GcnyGOccmF9ad1hX+9eN/u1OzeiggvcqSMAEofJuV4xXUVc/LD",
9
+ "bytes": 344010,
10
+ "gzipBytes": 103113
11
11
  },
12
12
  "drip.heatmap.js": {
13
- "sha384": "sha384-XJaQw2UA07kiwX/QOolq/OD/VZwp1qS+XKSkVxaz9lgl9RG9tZb4mW3VayRaQ0NB",
14
- "bytes": 350002,
15
- "gzipBytes": 104619
13
+ "sha384": "sha384-waxiWutviHM9hPp/hg3CeOK1K91RLc+6tqFw6ewVaLQzZ/VRRy0+4BFAQ9cFQWcf",
14
+ "bytes": 350459,
15
+ "gzipBytes": 104740
16
16
  },
17
17
  "drip.debug.js": {
18
- "sha384": "sha384-2URcohbse0uBuvenzE65vNNDop+upfeAEI5CoAJEMa9u3wQFwisZ+EKwhPDBK8ov",
19
- "bytes": 441770,
20
- "gzipBytes": 132090
18
+ "sha384": "sha384-7uTB3GwFz6Fs2eK0/CHn1Dwbu0xd9MGoAjgQwzrsHHoEnvsmsRjk61z0w+J7ivi4",
19
+ "bytes": 442227,
20
+ "gzipBytes": 132197
21
21
  },
22
22
  "editor.js": {
23
23
  "sha384": "sha384-OB10jEeM+Ci1L3cmdhp4MJyqko/f7lM+mcLfShixNRz145ucf9ZJaldhXCs++of5",
@@ -7,11 +7,12 @@ export type SynchronousConsentInput = {
7
7
  respectDoNotTrack?: boolean;
8
8
  doNotTrackValue?: string;
9
9
  };
10
- export type ConsentProvider = "custom" | "onetrust" | "usercentrics" | "cookiebot" | "ccm19" | "pandectes" | "cookiescript";
10
+ export type ConsentProvider = "custom" | "onetrust" | "usercentrics" | "cookiebot" | "ccm19" | "pandectes" | "cookiescript" | "borlabs";
11
11
  export declare function readPath(root: unknown, path?: string): unknown;
12
12
  export declare function readConsentCookie(name: string): string;
13
13
  /** The SDK's synchronous native-CMP readers, shared with the pre-SDK capture fragment. */
14
14
  export declare function readConfiguredConsent(provider?: ConsentProvider, requiredGroup?: string, getter?: string): boolean | null;
15
+ export declare function readBorlabsConsent(requiredGroup?: string): boolean | null;
15
16
  export declare function readCookieScriptConsent(requiredGroup?: string): boolean | null;
16
17
  export declare const CONSENT_REQUIRED = 1;
17
18
  export declare const CONSENT_GRANTED = 2;
@@ -49,7 +49,7 @@ export declare function clearEarlyInteractions(mode?: StorageMode): void;
49
49
  type ConsentConfig = {
50
50
  requireConsent?: boolean;
51
51
  consentModeEnabled?: boolean;
52
- consentProvider?: "custom" | "onetrust" | "usercentrics" | "cookiebot" | "ccm19" | "pandectes" | "cookiescript";
52
+ consentProvider?: "custom" | "onetrust" | "usercentrics" | "cookiebot" | "ccm19" | "pandectes" | "cookiescript" | "borlabs";
53
53
  consentRequiredGroup?: string;
54
54
  consentGetter?: string;
55
55
  respectDoNotTrack?: boolean;
@@ -20,7 +20,7 @@ export declare function computePredecided(input: {
20
20
  requireConsent?: boolean;
21
21
  hasConsent?: boolean;
22
22
  consentModeEnabled?: boolean;
23
- consentProvider?: "custom" | "onetrust" | "usercentrics" | "cookiebot" | "ccm19" | "pandectes" | "cookiescript";
23
+ consentProvider?: "custom" | "onetrust" | "usercentrics" | "cookiebot" | "ccm19" | "pandectes" | "cookiescript" | "borlabs";
24
24
  consentRequiredGroup?: string;
25
25
  respectDoNotTrack?: boolean;
26
26
  }): PredecidedAssignments;
@@ -284,7 +284,7 @@ export interface ProjectPrerequisites {
284
284
  }
285
285
  export interface ConsentModeSettings {
286
286
  enabled?: boolean;
287
- provider?: "custom" | "onetrust" | "usercentrics" | "cookiebot" | "ccm19" | "pandectes" | "cookiescript";
287
+ provider?: "custom" | "onetrust" | "usercentrics" | "cookiebot" | "ccm19" | "pandectes" | "cookiescript" | "borlabs";
288
288
  getter?: string;
289
289
  requiredGroup?: string;
290
290
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drip-apex/sdk",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "license": "MIT",
5
5
  "main": "./dist/drip.cjs",
6
6
  "types": "dist/types/index.d.ts",
@@ -817,6 +817,7 @@ export function shouldPollConfiguredConsent(config: InitConfig): boolean {
817
817
  return consent.provider === "custom"
818
818
  || consent.provider === "pandectes"
819
819
  || consent.provider === "cookiescript"
820
+ || consent.provider === "borlabs"
820
821
  || typeof consent.getter === "string";
821
822
  }
822
823
 
@@ -0,0 +1,41 @@
1
+ import { afterEach, describe, expect, it, vi } from "vitest";
2
+ import { readBorlabsConsent } from "./consent-evaluation";
3
+
4
+ describe("readBorlabsConsent", () => {
5
+ afterEach(() => {
6
+ delete (globalThis as Record<string, unknown>).BorlabsCookie;
7
+ if (typeof window !== "undefined") delete (window as unknown as Record<string, unknown>).BorlabsCookie;
8
+ });
9
+
10
+ it.each([true, false])("returns v3 service consent when hasConsent returns %s", (granted) => {
11
+ const hasConsent = vi.fn(() => granted);
12
+ const hasConsentForServiceGroup = vi.fn(() => false);
13
+ (globalThis as any).BorlabsCookie = { Consents: { hasConsent, hasConsentForServiceGroup } };
14
+
15
+ expect(readBorlabsConsent("apex-analytics")).toBe(granted);
16
+ expect(hasConsent).toHaveBeenCalledWith("apex-analytics");
17
+ expect(hasConsentForServiceGroup).toHaveBeenCalledTimes(granted ? 0 : 1);
18
+ });
19
+
20
+ it("falls back to the v3 service group API and defaults to statistics", () => {
21
+ const hasConsent = vi.fn(() => false);
22
+ const hasConsentForServiceGroup = vi.fn(() => true);
23
+ (globalThis as any).BorlabsCookie = { Consents: { hasConsent, hasConsentForServiceGroup } };
24
+
25
+ expect(readBorlabsConsent(" ")).toBe(true);
26
+ expect(hasConsent).toHaveBeenCalledWith("statistics");
27
+ expect(hasConsentForServiceGroup).toHaveBeenCalledWith("statistics");
28
+ });
29
+
30
+ it("falls back to the v2 API when v3 methods are unavailable", () => {
31
+ const checkCookieConsent = vi.fn(() => true);
32
+ (globalThis as any).BorlabsCookie = { checkCookieConsent };
33
+
34
+ expect(readBorlabsConsent("statistics")).toBe(true);
35
+ expect(checkCookieConsent).toHaveBeenCalledWith("statistics");
36
+ });
37
+
38
+ it("returns unknown when Borlabs is absent", () => {
39
+ expect(readBorlabsConsent()).toBeNull();
40
+ });
41
+ });
@@ -8,7 +8,7 @@ export type SynchronousConsentInput = {
8
8
  doNotTrackValue?: string;
9
9
  };
10
10
 
11
- export type ConsentProvider = "custom" | "onetrust" | "usercentrics" | "cookiebot" | "ccm19" | "pandectes" | "cookiescript";
11
+ export type ConsentProvider = "custom" | "onetrust" | "usercentrics" | "cookiebot" | "ccm19" | "pandectes" | "cookiescript" | "borlabs";
12
12
 
13
13
  export function readPath(root: unknown, path?: string): unknown {
14
14
  let current = root as Record<string, unknown> | undefined;
@@ -34,6 +34,7 @@ export function readConsentCookie(name: string): string {
34
34
  export function readConfiguredConsent(provider?: ConsentProvider, requiredGroup?: string, getter?: string): boolean | null {
35
35
  const root = globalThis as Record<string, any>;
36
36
  if (provider === "cookiescript") return readCookieScriptConsent(requiredGroup);
37
+ if (provider === "borlabs") return readBorlabsConsent(requiredGroup);
37
38
  if (provider === "usercentrics") {
38
39
  const uc = root.UC_UI ?? root.window?.UC_UI;
39
40
  if (typeof uc?.getServicesBaseInfo !== "function") return null;
@@ -82,6 +83,18 @@ export function readConfiguredConsent(provider?: ConsentProvider, requiredGroup?
82
83
  return null;
83
84
  }
84
85
 
86
+ export function readBorlabsConsent(requiredGroup?: string): boolean | null {
87
+ const root = globalThis as Record<string, any>;
88
+ const borlabs = root.BorlabsCookie ?? root.window?.BorlabsCookie;
89
+ if (!borlabs) return null;
90
+ const required = requiredGroup?.trim() || "statistics";
91
+ const consents = borlabs.Consents;
92
+ try { if (typeof consents?.hasConsent === "function" && consents.hasConsent(required)) return true; } catch {}
93
+ try { if (typeof consents?.hasConsentForServiceGroup === "function") return Boolean(consents.hasConsentForServiceGroup(required)); } catch {}
94
+ try { if (typeof borlabs.checkCookieConsent === "function") return Boolean(borlabs.checkCookieConsent(required)); } catch {}
95
+ return null;
96
+ }
97
+
85
98
  export function readCookieScriptConsent(requiredGroup?: string): boolean | null {
86
99
  const root = globalThis as Record<string, any>;
87
100
  const requested = (requiredGroup?.trim() || "analytics").toLowerCase();
@@ -143,7 +143,7 @@ function matchingElement(target: Element, goal: Goal, kind: "click" | "submit"):
143
143
  const match = target.closest(goal.selector); return match && (!goal.textMatch || (match.textContent || "").trim().toLowerCase().includes(goal.textMatch.trim().toLowerCase())) ? match : null;
144
144
  } catch { return null; }
145
145
  }
146
- type ConsentConfig = { requireConsent?: boolean; consentModeEnabled?: boolean; consentProvider?: "custom" | "onetrust" | "usercentrics" | "cookiebot" | "ccm19" | "pandectes" | "cookiescript"; consentRequiredGroup?: string; consentGetter?: string; respectDoNotTrack?: boolean };
146
+ type ConsentConfig = { requireConsent?: boolean; consentModeEnabled?: boolean; consentProvider?: "custom" | "onetrust" | "usercentrics" | "cookiebot" | "ccm19" | "pandectes" | "cookiescript" | "borlabs"; consentRequiredGroup?: string; consentGetter?: string; respectDoNotTrack?: boolean };
147
147
  export type EarlyCaptureConfig = ConsentConfig & { experiments: Experiment[]; assignments: Pick<Assignment, "experimentId" | "variationId" | "assignmentEpoch">[]; attributes?: Record<string, unknown>; configRevision: number; pageUrl: string; storageMode?: StorageMode; forcedExperimentIds?: string[]; now?: number };
148
148
  const CONSENT_EVENTS = ["OneTrustGroupsUpdated", "OptanonConsentChanged", "CookiebotOnConsentReady", "CookiebotOnAccept", "CookiebotOnDecline", "CookieConsentDeclaration", "UC_UI_CMP_EVENT", "ccm19EmbeddingAccepted", "ccm19WidgetClosed", "ccm19WidgetLoaded", "PandectesInitialized", "visitorConsentCollected", "CookieScriptLoaded", "CookieScriptAccept", "CookieScriptAcceptAll", "CookieScriptReject", "CookieScriptClose"];
149
149
 
@@ -30,7 +30,7 @@ export function computePredecided(input: {
30
30
  requireConsent?: boolean;
31
31
  hasConsent?: boolean;
32
32
  consentModeEnabled?: boolean;
33
- consentProvider?: "custom" | "onetrust" | "usercentrics" | "cookiebot" | "ccm19" | "pandectes" | "cookiescript";
33
+ consentProvider?: "custom" | "onetrust" | "usercentrics" | "cookiebot" | "ccm19" | "pandectes" | "cookiescript" | "borlabs";
34
34
  consentRequiredGroup?: string;
35
35
  respectDoNotTrack?: boolean;
36
36
  }): PredecidedAssignments {
package/src/types.ts CHANGED
@@ -346,7 +346,7 @@ export interface ProjectPrerequisites {
346
346
 
347
347
  export interface ConsentModeSettings {
348
348
  enabled?: boolean;
349
- provider?: "custom" | "onetrust" | "usercentrics" | "cookiebot" | "ccm19" | "pandectes" | "cookiescript";
349
+ provider?: "custom" | "onetrust" | "usercentrics" | "cookiebot" | "ccm19" | "pandectes" | "cookiescript" | "borlabs";
350
350
  getter?: string;
351
351
  requiredGroup?: string;
352
352
  }