From c6579904b0061360ac0a0455aa3d41da5d805e58 Mon Sep 17 00:00:00 2001 From: Eli Grey <~@eligrey.com> Date: Tue, 6 Aug 2024 11:55:31 -0700 Subject: [PATCH] Expose `airgap.isConsented()` (#140) --- package.json | 2 +- src/core.ts | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 19dbe8c..c454bf7 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "author": "Transcend Inc.", "name": "@transcend-io/airgap.js-types", "description": "TypeScript types for airgap.js interoperability with custom consent UIs", - "version": "11.0.0", + "version": "12.0.0", "homepage": "https://github.com/transcend-io/airgap.js-types", "repository": { "type": "git", diff --git a/src/core.ts b/src/core.ts index a48ce9e..b8eb99f 100644 --- a/src/core.ts +++ b/src/core.ts @@ -218,6 +218,9 @@ export type CookieOverride = (event: IPendingCookieMutation) => void; */ export type CookieWatcher = (event: IPendingCookieMutation) => void; +/** Event types (for purpose resolution) */ +export type TrackingEventType = 'request' | 'cookie'; + /** airgap.js API */ export type AirgapAPI = Readonly<{ /** Embedded request watchers */ @@ -237,6 +240,18 @@ export type AirgapAPI = Readonly<{ * @param resolveOverrides - Resolve overrides. Defaults to true. */ resolve(url: Stringifiable, resolveOverrides?: boolean): Stringifiable; + /** + * Resolve consent status for given tracking purposes. Essential purposes override opted out unessential purposes. + * + * If `use` is not provided, consent is resolved for both request and cookie tracking event types. + * @param trackingPurposes - Tracking purposes to resolve + * @param use - Optional event type to use for tracking purpose resolution + * @returns `true` if the applicable tracking purposes are consented. + */ + isConsented( + trackingPurposes: TrackingPurposes, + use?: TrackingEventType, + ): boolean; /** Get tracking consent */ getConsent(): TrackingConsentDetails; /** Set tracking consent */