@guardian/commercial-core 30.2.0 → 31.0.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/cjs/ad-sizes.d.ts +1 -1
- package/dist/cjs/ad-sizes.js +1 -1
- package/dist/cjs/constants/index.d.ts +3 -3
- package/dist/cjs/constants/index.js +3 -3
- package/dist/cjs/email-hash.d.ts +1 -1
- package/dist/cjs/email-hash.js +13 -12
- package/dist/cjs/event-timer.d.ts +6 -1
- package/dist/cjs/geo/geo-utils.js +1 -1
- package/dist/cjs/global.d.ts +8 -72
- package/dist/cjs/index.d.ts +14 -14
- package/dist/cjs/index.js +11 -11
- package/dist/cjs/send-commercial-metrics.d.ts +1 -1
- package/dist/cjs/send-commercial-metrics.js +1 -1
- package/dist/cjs/targeting/build-page-targeting.d.ts +5 -5
- package/dist/cjs/targeting/build-page-targeting.js +7 -7
- package/dist/cjs/targeting/youtube-ima.d.ts +1 -1
- package/dist/cjs/targeting/youtube-ima.js +1 -1
- package/dist/cjs/types.d.ts +18 -38
- package/dist/cjs/types.js +0 -1
- package/dist/esm/email-hash.d.ts +1 -1
- package/dist/esm/email-hash.js +13 -12
- package/dist/esm/event-timer.d.ts +6 -1
- package/dist/esm/global.d.ts +8 -72
- package/dist/esm/targeting/build-page-targeting.d.ts +1 -1
- package/dist/esm/types.d.ts +17 -37
- package/dist/esm/types.js +0 -1
- package/package.json +6 -7
package/dist/cjs/ad-sizes.d.ts
CHANGED
package/dist/cjs/ad-sizes.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.findAppliedSizesForBreakpoint = exports.createAdSize = exports.slotSizeMappings = exports.getAdSize = exports.outstreamSizes = exports.standardAdSizes = exports.adSizes = exports.AdSize = exports._ = void 0;
|
|
4
|
-
const breakpoint_1 = require("./breakpoint
|
|
4
|
+
const breakpoint_1 = require("./breakpoint");
|
|
5
5
|
/**
|
|
6
6
|
* Store ad sizes in a way that is compatible with google-tag but also accessible via
|
|
7
7
|
* more semantic `width`/`height` properties and keep things readonly.
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { AD_LABEL_HEIGHT } from './ad-label-height
|
|
2
|
-
export { PREBID_TIMEOUT } from './prebid-timeout
|
|
3
|
-
export { TOP_ABOVE_NAV_HEIGHT } from './top-above-nav-height
|
|
1
|
+
export { AD_LABEL_HEIGHT } from './ad-label-height';
|
|
2
|
+
export { PREBID_TIMEOUT } from './prebid-timeout';
|
|
3
|
+
export { TOP_ABOVE_NAV_HEIGHT } from './top-above-nav-height';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TOP_ABOVE_NAV_HEIGHT = exports.PREBID_TIMEOUT = exports.AD_LABEL_HEIGHT = void 0;
|
|
4
|
-
var ad_label_height_1 = require("./ad-label-height
|
|
4
|
+
var ad_label_height_1 = require("./ad-label-height");
|
|
5
5
|
Object.defineProperty(exports, "AD_LABEL_HEIGHT", { enumerable: true, get: function () { return ad_label_height_1.AD_LABEL_HEIGHT; } });
|
|
6
|
-
var prebid_timeout_1 = require("./prebid-timeout
|
|
6
|
+
var prebid_timeout_1 = require("./prebid-timeout");
|
|
7
7
|
Object.defineProperty(exports, "PREBID_TIMEOUT", { enumerable: true, get: function () { return prebid_timeout_1.PREBID_TIMEOUT; } });
|
|
8
|
-
var top_above_nav_height_1 = require("./top-above-nav-height
|
|
8
|
+
var top_above_nav_height_1 = require("./top-above-nav-height");
|
|
9
9
|
Object.defineProperty(exports, "TOP_ABOVE_NAV_HEIGHT", { enumerable: true, get: function () { return top_above_nav_height_1.TOP_ABOVE_NAV_HEIGHT; } });
|
package/dist/cjs/email-hash.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
type HashClient = 'id5' | '
|
|
1
|
+
type HashClient = 'euid' | 'id5' | 'liveramp' | 'uid2';
|
|
2
2
|
type Email = `${string}@${string}`;
|
|
3
3
|
declare function normaliseEmail(email: string): Email;
|
|
4
4
|
declare function hashEmailForClient(email: string, client: HashClient): Promise<string>;
|
package/dist/cjs/email-hash.js
CHANGED
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.hashEmailForClient = hashEmailForClient;
|
|
4
4
|
exports.normaliseEmail = normaliseEmail;
|
|
5
|
-
function
|
|
6
|
-
const
|
|
5
|
+
function toBase64(content) {
|
|
6
|
+
const hashBytes = new Uint8Array(content);
|
|
7
|
+
const base64Hash = btoa(String.fromCharCode(...hashBytes));
|
|
8
|
+
return base64Hash;
|
|
9
|
+
}
|
|
10
|
+
function toHex(content) {
|
|
11
|
+
const hashArray = Array.from(new Uint8Array(content));
|
|
7
12
|
const hashHex = hashArray
|
|
8
13
|
.map((bytes) => bytes.toString(16).padStart(2, '0'))
|
|
9
14
|
.join('');
|
|
10
15
|
return hashHex;
|
|
11
16
|
}
|
|
12
|
-
function toBase64(hashBuffer) {
|
|
13
|
-
const hashBytes = new Uint8Array(hashBuffer);
|
|
14
|
-
const base64Hash = btoa(String.fromCharCode(...hashBytes));
|
|
15
|
-
return base64Hash;
|
|
16
|
-
}
|
|
17
17
|
function normaliseEmail(email) {
|
|
18
18
|
const normalisedEmail = email.trim().toLowerCase();
|
|
19
19
|
const [name, domain] = normalisedEmail.split('@');
|
|
@@ -25,13 +25,14 @@ function normaliseEmail(email) {
|
|
|
25
25
|
}
|
|
26
26
|
async function hashEmailForClient(email, client) {
|
|
27
27
|
const normalisedEmail = normaliseEmail(email);
|
|
28
|
-
const
|
|
29
|
-
const hashBuffer = await crypto.subtle.digest('SHA-256',
|
|
28
|
+
const textAsBuffer = new TextEncoder().encode(normalisedEmail);
|
|
29
|
+
const hashBuffer = await crypto.subtle.digest('SHA-256', textAsBuffer);
|
|
30
30
|
switch (client) {
|
|
31
|
-
case 'id5':
|
|
32
|
-
return toHex(hashBuffer);
|
|
33
|
-
case 'uid2':
|
|
34
31
|
case 'euid':
|
|
32
|
+
case 'uid2':
|
|
35
33
|
return toBase64(hashBuffer);
|
|
34
|
+
case 'id5':
|
|
35
|
+
case 'liveramp':
|
|
36
|
+
return toHex(hashBuffer);
|
|
36
37
|
}
|
|
37
38
|
}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import type { ConnectionType } from './types.js';
|
|
1
|
+
import type { ConnectionType, NetworkInformation } from './types.js';
|
|
2
|
+
declare global {
|
|
3
|
+
interface Navigator {
|
|
4
|
+
readonly connection?: NetworkInformation;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
2
7
|
declare const supportsPerformanceAPI: () => boolean;
|
|
3
8
|
interface EventTimerProperties {
|
|
4
9
|
type?: ConnectionType;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports._ = exports.isInRow = exports.isInAuOrNz = exports.isInUsOrCa = exports.isInNewZealand = exports.isInAustralia = exports.isInCanada = exports.isInUsa = exports.isInUk = void 0;
|
|
4
|
-
const country_code_1 = require("./country-code
|
|
4
|
+
const country_code_1 = require("./country-code");
|
|
5
5
|
// cache the users location so we only have to look it up once
|
|
6
6
|
let geo;
|
|
7
7
|
const currentGeoLocation = () => {
|
package/dist/cjs/global.d.ts
CHANGED
|
@@ -1,77 +1,13 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { AdBlockers, Admiral, Apstag, ArticleCounts, ComscoreGlobals, Confiant, Config, DfpEnv, FetchBidResponse, GoogleTagParams, GoogleTrackConversionObject, HeaderNotification, IasPET, NetworkInformation, NSdkInstance, Ophan, OptOutAdSlot, OptOutInitializeOptions, Permutive, SafeFrameAPI, TeadsAnalytics, Trac } from './types.js';
|
|
1
|
+
import type { CoreGuardian } from './types';
|
|
3
2
|
declare global {
|
|
4
|
-
interface Navigator {
|
|
5
|
-
readonly connection?: NetworkInformation;
|
|
6
|
-
readonly cookieDeprecationLabel?: {
|
|
7
|
-
getValue: () => Promise<string>;
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
3
|
interface Window {
|
|
11
|
-
guardian:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
adBlockers: AdBlockers;
|
|
18
|
-
css: {
|
|
19
|
-
onLoad: () => void;
|
|
20
|
-
loaded: boolean;
|
|
21
|
-
};
|
|
22
|
-
articleCounts?: ArticleCounts;
|
|
23
|
-
commercial?: {
|
|
24
|
-
dfpEnv?: DfpEnv;
|
|
25
|
-
a9WinningBids?: FetchBidResponse[];
|
|
26
|
-
};
|
|
27
|
-
notificationEventHistory?: HeaderNotification[][];
|
|
28
|
-
commercialTimer?: EventTimer;
|
|
29
|
-
offlineCount?: number;
|
|
30
|
-
modules: {
|
|
31
|
-
sentry?: {
|
|
32
|
-
reportError?: (error: Error, feature: string, tags?: Record<string, string>, extras?: Record<string, unknown>) => void;
|
|
33
|
-
};
|
|
34
|
-
abTests?: {
|
|
35
|
-
getParticipations: () => Record<string, string>;
|
|
36
|
-
isUserInTest: (testId: string) => boolean;
|
|
37
|
-
isUserInTestGroup: (testId: string, variantId: string) => boolean;
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
ootag: {
|
|
42
|
-
queue: Array<() => void>;
|
|
43
|
-
initializeOo: (o: OptOutInitializeOptions) => void;
|
|
44
|
-
addParameter: (key: string, value: string | string[]) => void;
|
|
45
|
-
addParameterForSlot: (slotId: string, key: string, value: string | string[]) => void;
|
|
46
|
-
defineSlot: (o: OptOutAdSlot) => void;
|
|
47
|
-
makeRequests: () => void;
|
|
48
|
-
refreshSlot: (slotId: string) => void;
|
|
49
|
-
refreshAllSlots: () => void;
|
|
50
|
-
logger: (...args: unknown[]) => void;
|
|
51
|
-
};
|
|
52
|
-
readonly navigator: Navigator;
|
|
53
|
-
confiant?: Confiant;
|
|
54
|
-
apstag?: Apstag;
|
|
55
|
-
permutive?: Permutive;
|
|
56
|
-
_comscore?: ComscoreGlobals[];
|
|
57
|
-
__iasPET?: IasPET;
|
|
58
|
-
teads_analytics?: TeadsAnalytics;
|
|
59
|
-
$sf: SafeFrameAPI;
|
|
60
|
-
conf: unknown;
|
|
61
|
-
NOLCMB: {
|
|
62
|
-
getInstance: (apid: string) => NSdkInstance;
|
|
4
|
+
guardian: CoreGuardian;
|
|
5
|
+
googletag: {
|
|
6
|
+
getConfig?: <Key extends string>(key: Key) => Key extends 'targeting' ? {
|
|
7
|
+
targeting: Record<string, string | string[]>;
|
|
8
|
+
} : unknown;
|
|
9
|
+
pubads: () => unknown;
|
|
63
10
|
};
|
|
64
|
-
nol_t: (pvar: {
|
|
65
|
-
cid: string;
|
|
66
|
-
content: string;
|
|
67
|
-
server: string;
|
|
68
|
-
}) => Trac;
|
|
69
|
-
google_trackConversion?: (arg0: GoogleTrackConversionObject) => void;
|
|
70
|
-
google_tag_params?: GoogleTagParams;
|
|
71
|
-
_brandmetrics?: Array<{
|
|
72
|
-
cmd: string;
|
|
73
|
-
val: Record<string, unknown>;
|
|
74
|
-
}>;
|
|
75
|
-
admiral?: Admiral;
|
|
76
11
|
}
|
|
77
12
|
}
|
|
13
|
+
export type { CoreGuardian };
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export { isAdBlockInUse } from './detect-ad-blocker
|
|
2
|
-
export { EventTimer } from './event-timer
|
|
3
|
-
export { adSizes } from './ad-sizes
|
|
4
|
-
export * as constants from './constants
|
|
5
|
-
export { bypassCommercialMetricsSampling, initCommercialMetrics, } from './send-commercial-metrics
|
|
6
|
-
export { buildPageTargeting } from './targeting/build-page-targeting
|
|
7
|
-
export { postMessage } from './messenger/post-message
|
|
8
|
-
export { buildImaAdTagUrl } from './targeting/youtube-ima
|
|
9
|
-
export { getPermutivePFPSegments } from './permutive
|
|
10
|
-
export { isEligibleForTeads } from './targeting/teads-eligibility
|
|
11
|
-
export { hashEmailForClient } from './email-hash
|
|
12
|
-
export type { AdSize, SizeMapping, SlotName } from './ad-sizes
|
|
13
|
-
export type { PageTargeting } from './targeting/build-page-targeting
|
|
14
|
-
export type { AdsConfigDisabled, AdsConfigUSNATorAus, AdsConfigTCFV2, } from './types
|
|
1
|
+
export { isAdBlockInUse } from './detect-ad-blocker';
|
|
2
|
+
export { EventTimer } from './event-timer';
|
|
3
|
+
export { adSizes } from './ad-sizes';
|
|
4
|
+
export * as constants from './constants';
|
|
5
|
+
export { bypassCommercialMetricsSampling, initCommercialMetrics, } from './send-commercial-metrics';
|
|
6
|
+
export { buildPageTargeting } from './targeting/build-page-targeting';
|
|
7
|
+
export { postMessage } from './messenger/post-message';
|
|
8
|
+
export { buildImaAdTagUrl } from './targeting/youtube-ima';
|
|
9
|
+
export { getPermutivePFPSegments } from './permutive';
|
|
10
|
+
export { isEligibleForTeads } from './targeting/teads-eligibility';
|
|
11
|
+
export { hashEmailForClient } from './email-hash';
|
|
12
|
+
export type { AdSize, SizeMapping, SlotName } from './ad-sizes';
|
|
13
|
+
export type { PageTargeting } from './targeting/build-page-targeting';
|
|
14
|
+
export type { AdsConfigDisabled, AdsConfigUSNATorAus, AdsConfigTCFV2, } from './types';
|
package/dist/cjs/index.js
CHANGED
|
@@ -34,25 +34,25 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.hashEmailForClient = exports.isEligibleForTeads = exports.getPermutivePFPSegments = exports.buildImaAdTagUrl = exports.buildPageTargeting = exports.initCommercialMetrics = exports.bypassCommercialMetricsSampling = exports.constants = exports.adSizes = exports.EventTimer = exports.isAdBlockInUse = void 0;
|
|
37
|
-
var detect_ad_blocker_1 = require("./detect-ad-blocker
|
|
37
|
+
var detect_ad_blocker_1 = require("./detect-ad-blocker");
|
|
38
38
|
Object.defineProperty(exports, "isAdBlockInUse", { enumerable: true, get: function () { return detect_ad_blocker_1.isAdBlockInUse; } });
|
|
39
|
-
var event_timer_1 = require("./event-timer
|
|
39
|
+
var event_timer_1 = require("./event-timer");
|
|
40
40
|
Object.defineProperty(exports, "EventTimer", { enumerable: true, get: function () { return event_timer_1.EventTimer; } });
|
|
41
|
-
var ad_sizes_1 = require("./ad-sizes
|
|
41
|
+
var ad_sizes_1 = require("./ad-sizes");
|
|
42
42
|
Object.defineProperty(exports, "adSizes", { enumerable: true, get: function () { return ad_sizes_1.adSizes; } });
|
|
43
|
-
exports.constants = __importStar(require("./constants
|
|
44
|
-
var send_commercial_metrics_1 = require("./send-commercial-metrics
|
|
43
|
+
exports.constants = __importStar(require("./constants"));
|
|
44
|
+
var send_commercial_metrics_1 = require("./send-commercial-metrics");
|
|
45
45
|
Object.defineProperty(exports, "bypassCommercialMetricsSampling", { enumerable: true, get: function () { return send_commercial_metrics_1.bypassCommercialMetricsSampling; } });
|
|
46
46
|
Object.defineProperty(exports, "initCommercialMetrics", { enumerable: true, get: function () { return send_commercial_metrics_1.initCommercialMetrics; } });
|
|
47
|
-
var build_page_targeting_1 = require("./targeting/build-page-targeting
|
|
47
|
+
var build_page_targeting_1 = require("./targeting/build-page-targeting");
|
|
48
48
|
Object.defineProperty(exports, "buildPageTargeting", { enumerable: true, get: function () { return build_page_targeting_1.buildPageTargeting; } });
|
|
49
|
-
var post_message_1 = require("./messenger/post-message
|
|
49
|
+
var post_message_1 = require("./messenger/post-message");
|
|
50
50
|
Object.defineProperty(exports, "postMessage", { enumerable: true, get: function () { return post_message_1.postMessage; } });
|
|
51
|
-
var youtube_ima_1 = require("./targeting/youtube-ima
|
|
51
|
+
var youtube_ima_1 = require("./targeting/youtube-ima");
|
|
52
52
|
Object.defineProperty(exports, "buildImaAdTagUrl", { enumerable: true, get: function () { return youtube_ima_1.buildImaAdTagUrl; } });
|
|
53
|
-
var permutive_1 = require("./permutive
|
|
53
|
+
var permutive_1 = require("./permutive");
|
|
54
54
|
Object.defineProperty(exports, "getPermutivePFPSegments", { enumerable: true, get: function () { return permutive_1.getPermutivePFPSegments; } });
|
|
55
|
-
var teads_eligibility_1 = require("./targeting/teads-eligibility
|
|
55
|
+
var teads_eligibility_1 = require("./targeting/teads-eligibility");
|
|
56
56
|
Object.defineProperty(exports, "isEligibleForTeads", { enumerable: true, get: function () { return teads_eligibility_1.isEligibleForTeads; } });
|
|
57
|
-
var email_hash_1 = require("./email-hash
|
|
57
|
+
var email_hash_1 = require("./email-hash");
|
|
58
58
|
Object.defineProperty(exports, "hashEmailForClient", { enumerable: true, get: function () { return email_hash_1.hashEmailForClient; } });
|
|
@@ -4,7 +4,7 @@ exports.checkConsent = exports._ = void 0;
|
|
|
4
4
|
exports.bypassCommercialMetricsSampling = bypassCommercialMetricsSampling;
|
|
5
5
|
exports.initCommercialMetrics = initCommercialMetrics;
|
|
6
6
|
const libs_1 = require("@guardian/libs");
|
|
7
|
-
const event_timer_1 = require("./event-timer
|
|
7
|
+
const event_timer_1 = require("./event-timer");
|
|
8
8
|
var Endpoints;
|
|
9
9
|
(function (Endpoints) {
|
|
10
10
|
Endpoints["CODE"] = "//performance-events.code.dev-guardianapis.com/commercial-metrics";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { Participations } from '@guardian/ab-core';
|
|
2
2
|
import type { ConsentState, CountryCode } from '@guardian/libs';
|
|
3
|
-
import type { AdManagerGroup, Frequency } from './personalised
|
|
4
|
-
import type { SharedTargeting } from './shared
|
|
5
|
-
import { getLocalHour } from './shared
|
|
6
|
-
import type { TrueOrFalse } from './types
|
|
3
|
+
import type { AdManagerGroup, Frequency } from './personalised';
|
|
4
|
+
import type { SharedTargeting } from './shared';
|
|
5
|
+
import { getLocalHour } from './shared';
|
|
6
|
+
import type { TrueOrFalse } from './types';
|
|
7
7
|
type PartialWithNulls<T> = {
|
|
8
8
|
[P in keyof T]?: T[P] | null;
|
|
9
9
|
};
|
|
@@ -40,7 +40,7 @@ type PageTargeting = PartialWithNulls<{
|
|
|
40
40
|
declare const filterValues: (pageTargets: Record<string, unknown>) => Record<string, string | string[]>;
|
|
41
41
|
type UserId = {
|
|
42
42
|
name: string;
|
|
43
|
-
params?: Record<string, string | number
|
|
43
|
+
params?: Record<string, string | number | boolean | Record<string, unknown>>;
|
|
44
44
|
storage?: {
|
|
45
45
|
type: 'cookie' | 'html5';
|
|
46
46
|
name: string;
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getLocalHour = exports.filterValues = exports.buildPageTargeting = void 0;
|
|
4
4
|
const libs_1 = require("@guardian/libs");
|
|
5
|
-
const event_timer_1 = require("../event-timer
|
|
6
|
-
const get_locale_1 = require("../geo/get-locale
|
|
7
|
-
const content_1 = require("./content
|
|
8
|
-
const personalised_1 = require("./personalised
|
|
9
|
-
const session_1 = require("./session
|
|
10
|
-
const shared_1 = require("./shared
|
|
5
|
+
const event_timer_1 = require("../event-timer");
|
|
6
|
+
const get_locale_1 = require("../geo/get-locale");
|
|
7
|
+
const content_1 = require("./content");
|
|
8
|
+
const personalised_1 = require("./personalised");
|
|
9
|
+
const session_1 = require("./session");
|
|
10
|
+
const shared_1 = require("./shared");
|
|
11
11
|
Object.defineProperty(exports, "getLocalHour", { enumerable: true, get: function () { return shared_1.getLocalHour; } });
|
|
12
|
-
const viewport_1 = require("./viewport
|
|
12
|
+
const viewport_1 = require("./viewport");
|
|
13
13
|
const filterValues = (pageTargets) => {
|
|
14
14
|
const filtered = {};
|
|
15
15
|
for (const key in pageTargets) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Participations } from '@guardian/ab-core';
|
|
2
2
|
import type { ConsentState } from '@guardian/libs';
|
|
3
|
-
import type { CustomParams } from './types
|
|
3
|
+
import type { CustomParams } from './types';
|
|
4
4
|
type BuildImaAdTagUrl = {
|
|
5
5
|
adUnit: string;
|
|
6
6
|
customParams: CustomParams;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.buildImaAdTagUrl = void 0;
|
|
4
4
|
const libs_1 = require("@guardian/libs");
|
|
5
|
-
const build_page_targeting_1 = require("./build-page-targeting
|
|
5
|
+
const build_page_targeting_1 = require("./build-page-targeting");
|
|
6
6
|
/**
|
|
7
7
|
* @param {Record<string, MaybeArray<string|number|boolean>>
|
|
8
8
|
* Follows https://support.google.com/admanager/answer/1080597
|
package/dist/cjs/types.d.ts
CHANGED
|
@@ -1,41 +1,6 @@
|
|
|
1
1
|
import type { EventPayload } from '@guardian/ophan-tracker-js';
|
|
2
|
-
import type {
|
|
3
|
-
import type { PageTargeting } from './targeting/build-page-targeting
|
|
4
|
-
import '@types/google-publisher-tag';
|
|
5
|
-
type HeaderBiddingSize = AdSize;
|
|
6
|
-
interface Advert {
|
|
7
|
-
id: string;
|
|
8
|
-
node: HTMLElement;
|
|
9
|
-
sizes: SizeMapping;
|
|
10
|
-
headerBiddingSizes: HeaderBiddingSize[] | null;
|
|
11
|
-
size: AdSize | 'fluid' | null;
|
|
12
|
-
slot: googletag.Slot;
|
|
13
|
-
gpid: string | undefined;
|
|
14
|
-
isEmpty: boolean | null;
|
|
15
|
-
isRendered: boolean;
|
|
16
|
-
shouldRefresh: boolean;
|
|
17
|
-
whenSlotReady: Promise<void>;
|
|
18
|
-
extraNodeClasses: string[];
|
|
19
|
-
hasPrebidSize: boolean;
|
|
20
|
-
headerBiddingBidRequest: Promise<unknown> | null;
|
|
21
|
-
lineItemId: number | null;
|
|
22
|
-
creativeId: number | null;
|
|
23
|
-
creativeTemplateId: number | null;
|
|
24
|
-
testgroup: string | undefined;
|
|
25
|
-
finishedRendering(isRendered: boolean): void;
|
|
26
|
-
updateExtraSlotClasses(...newClasses: string[]): Promise<void>;
|
|
27
|
-
generateSizeMapping(additionalSizeMapping: SizeMapping): SizeMapping;
|
|
28
|
-
updateSizeMapping(additionalSizeMapping: SizeMapping): void;
|
|
29
|
-
}
|
|
30
|
-
interface DfpEnv {
|
|
31
|
-
renderStartTime: number;
|
|
32
|
-
adSlotSelector: string;
|
|
33
|
-
lazyLoadEnabled: boolean;
|
|
34
|
-
lazyLoadObserve: boolean;
|
|
35
|
-
advertsToLoad: Advert[];
|
|
36
|
-
adverts: Map<Advert['id'], Advert>;
|
|
37
|
-
shouldLazyLoad: () => boolean;
|
|
38
|
-
}
|
|
2
|
+
import type { EventTimer } from './event-timer';
|
|
3
|
+
import type { PageTargeting } from './targeting/build-page-targeting';
|
|
39
4
|
type ConnectionType = 'bluetooth' | 'cellular' | 'ethernet' | 'mixed' | 'none' | 'other' | 'unknown' | 'wifi';
|
|
40
5
|
interface NetworkInformation extends EventTarget {
|
|
41
6
|
readonly type?: ConnectionType;
|
|
@@ -430,4 +395,19 @@ type AdmiralEvent = Record<string, unknown>;
|
|
|
430
395
|
type AdmiralCallback = (event: AdmiralEvent) => void;
|
|
431
396
|
type AdmiralArg = string | AdmiralCallback;
|
|
432
397
|
type Admiral = (...args: AdmiralArg[]) => void;
|
|
433
|
-
|
|
398
|
+
interface CoreGuardian {
|
|
399
|
+
config: Config;
|
|
400
|
+
commercialTimer?: EventTimer;
|
|
401
|
+
offlineCount?: number;
|
|
402
|
+
modules: {
|
|
403
|
+
sentry?: {
|
|
404
|
+
reportError?: (error: Error, feature: string, tags?: Record<string, string>, extras?: Record<string, unknown>) => void;
|
|
405
|
+
};
|
|
406
|
+
abTests?: {
|
|
407
|
+
getParticipations: () => Record<string, string>;
|
|
408
|
+
isUserInTest: (testId: string) => boolean;
|
|
409
|
+
isUserInTestGroup: (testId: string, variantId: string) => boolean;
|
|
410
|
+
};
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
export type { ConnectionType, NetworkInformation, OphanRecordFunction, Indices, Edition, AdsConfigDisabled, AdsConfigEnabled, AdsConfigBasic, AdsConfigUSNATorAus, AdsConfigTCFV2, AdsConfig, AdTargetingBuilder, Ophan, Config, AdBlockers, ArticleCounts, FetchBidResponse, HeaderNotification, OptOutInitializeOptions, OptOutAdSlot, Confiant, Permutive, Apstag, ComscoreGlobals, IasPET, TeadsAnalytics, SafeFrameAPI, NSdkInstance, Trac, GoogleTagParams, GoogleTrackConversionObject, Admiral, AdmiralEvent, CoreGuardian, };
|
package/dist/cjs/types.js
CHANGED
package/dist/esm/email-hash.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
type HashClient = 'id5' | '
|
|
1
|
+
type HashClient = 'euid' | 'id5' | 'liveramp' | 'uid2';
|
|
2
2
|
type Email = `${string}@${string}`;
|
|
3
3
|
declare function normaliseEmail(email: string): Email;
|
|
4
4
|
declare function hashEmailForClient(email: string, client: HashClient): Promise<string>;
|
package/dist/esm/email-hash.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
function
|
|
2
|
-
const
|
|
1
|
+
function toBase64(content) {
|
|
2
|
+
const hashBytes = new Uint8Array(content);
|
|
3
|
+
const base64Hash = btoa(String.fromCharCode(...hashBytes));
|
|
4
|
+
return base64Hash;
|
|
5
|
+
}
|
|
6
|
+
function toHex(content) {
|
|
7
|
+
const hashArray = Array.from(new Uint8Array(content));
|
|
3
8
|
const hashHex = hashArray
|
|
4
9
|
.map((bytes) => bytes.toString(16).padStart(2, '0'))
|
|
5
10
|
.join('');
|
|
6
11
|
return hashHex;
|
|
7
12
|
}
|
|
8
|
-
function toBase64(hashBuffer) {
|
|
9
|
-
const hashBytes = new Uint8Array(hashBuffer);
|
|
10
|
-
const base64Hash = btoa(String.fromCharCode(...hashBytes));
|
|
11
|
-
return base64Hash;
|
|
12
|
-
}
|
|
13
13
|
function normaliseEmail(email) {
|
|
14
14
|
const normalisedEmail = email.trim().toLowerCase();
|
|
15
15
|
const [name, domain] = normalisedEmail.split('@');
|
|
@@ -21,14 +21,15 @@ function normaliseEmail(email) {
|
|
|
21
21
|
}
|
|
22
22
|
async function hashEmailForClient(email, client) {
|
|
23
23
|
const normalisedEmail = normaliseEmail(email);
|
|
24
|
-
const
|
|
25
|
-
const hashBuffer = await crypto.subtle.digest('SHA-256',
|
|
24
|
+
const textAsBuffer = new TextEncoder().encode(normalisedEmail);
|
|
25
|
+
const hashBuffer = await crypto.subtle.digest('SHA-256', textAsBuffer);
|
|
26
26
|
switch (client) {
|
|
27
|
-
case 'id5':
|
|
28
|
-
return toHex(hashBuffer);
|
|
29
|
-
case 'uid2':
|
|
30
27
|
case 'euid':
|
|
28
|
+
case 'uid2':
|
|
31
29
|
return toBase64(hashBuffer);
|
|
30
|
+
case 'id5':
|
|
31
|
+
case 'liveramp':
|
|
32
|
+
return toHex(hashBuffer);
|
|
32
33
|
}
|
|
33
34
|
}
|
|
34
35
|
export { hashEmailForClient, normaliseEmail };
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import type { ConnectionType } from './types.js';
|
|
1
|
+
import type { ConnectionType, NetworkInformation } from './types.js';
|
|
2
|
+
declare global {
|
|
3
|
+
interface Navigator {
|
|
4
|
+
readonly connection?: NetworkInformation;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
2
7
|
declare const supportsPerformanceAPI: () => boolean;
|
|
3
8
|
interface EventTimerProperties {
|
|
4
9
|
type?: ConnectionType;
|
package/dist/esm/global.d.ts
CHANGED
|
@@ -1,77 +1,13 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { AdBlockers, Admiral, Apstag, ArticleCounts, ComscoreGlobals, Confiant, Config, DfpEnv, FetchBidResponse, GoogleTagParams, GoogleTrackConversionObject, HeaderNotification, IasPET, NetworkInformation, NSdkInstance, Ophan, OptOutAdSlot, OptOutInitializeOptions, Permutive, SafeFrameAPI, TeadsAnalytics, Trac } from './types.js';
|
|
1
|
+
import type { CoreGuardian } from './types.js';
|
|
3
2
|
declare global {
|
|
4
|
-
interface Navigator {
|
|
5
|
-
readonly connection?: NetworkInformation;
|
|
6
|
-
readonly cookieDeprecationLabel?: {
|
|
7
|
-
getValue: () => Promise<string>;
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
3
|
interface Window {
|
|
11
|
-
guardian:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
adBlockers: AdBlockers;
|
|
18
|
-
css: {
|
|
19
|
-
onLoad: () => void;
|
|
20
|
-
loaded: boolean;
|
|
21
|
-
};
|
|
22
|
-
articleCounts?: ArticleCounts;
|
|
23
|
-
commercial?: {
|
|
24
|
-
dfpEnv?: DfpEnv;
|
|
25
|
-
a9WinningBids?: FetchBidResponse[];
|
|
26
|
-
};
|
|
27
|
-
notificationEventHistory?: HeaderNotification[][];
|
|
28
|
-
commercialTimer?: EventTimer;
|
|
29
|
-
offlineCount?: number;
|
|
30
|
-
modules: {
|
|
31
|
-
sentry?: {
|
|
32
|
-
reportError?: (error: Error, feature: string, tags?: Record<string, string>, extras?: Record<string, unknown>) => void;
|
|
33
|
-
};
|
|
34
|
-
abTests?: {
|
|
35
|
-
getParticipations: () => Record<string, string>;
|
|
36
|
-
isUserInTest: (testId: string) => boolean;
|
|
37
|
-
isUserInTestGroup: (testId: string, variantId: string) => boolean;
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
ootag: {
|
|
42
|
-
queue: Array<() => void>;
|
|
43
|
-
initializeOo: (o: OptOutInitializeOptions) => void;
|
|
44
|
-
addParameter: (key: string, value: string | string[]) => void;
|
|
45
|
-
addParameterForSlot: (slotId: string, key: string, value: string | string[]) => void;
|
|
46
|
-
defineSlot: (o: OptOutAdSlot) => void;
|
|
47
|
-
makeRequests: () => void;
|
|
48
|
-
refreshSlot: (slotId: string) => void;
|
|
49
|
-
refreshAllSlots: () => void;
|
|
50
|
-
logger: (...args: unknown[]) => void;
|
|
51
|
-
};
|
|
52
|
-
readonly navigator: Navigator;
|
|
53
|
-
confiant?: Confiant;
|
|
54
|
-
apstag?: Apstag;
|
|
55
|
-
permutive?: Permutive;
|
|
56
|
-
_comscore?: ComscoreGlobals[];
|
|
57
|
-
__iasPET?: IasPET;
|
|
58
|
-
teads_analytics?: TeadsAnalytics;
|
|
59
|
-
$sf: SafeFrameAPI;
|
|
60
|
-
conf: unknown;
|
|
61
|
-
NOLCMB: {
|
|
62
|
-
getInstance: (apid: string) => NSdkInstance;
|
|
4
|
+
guardian: CoreGuardian;
|
|
5
|
+
googletag: {
|
|
6
|
+
getConfig?: <Key extends string>(key: Key) => Key extends 'targeting' ? {
|
|
7
|
+
targeting: Record<string, string | string[]>;
|
|
8
|
+
} : unknown;
|
|
9
|
+
pubads: () => unknown;
|
|
63
10
|
};
|
|
64
|
-
nol_t: (pvar: {
|
|
65
|
-
cid: string;
|
|
66
|
-
content: string;
|
|
67
|
-
server: string;
|
|
68
|
-
}) => Trac;
|
|
69
|
-
google_trackConversion?: (arg0: GoogleTrackConversionObject) => void;
|
|
70
|
-
google_tag_params?: GoogleTagParams;
|
|
71
|
-
_brandmetrics?: Array<{
|
|
72
|
-
cmd: string;
|
|
73
|
-
val: Record<string, unknown>;
|
|
74
|
-
}>;
|
|
75
|
-
admiral?: Admiral;
|
|
76
11
|
}
|
|
77
12
|
}
|
|
13
|
+
export type { CoreGuardian };
|
|
@@ -40,7 +40,7 @@ type PageTargeting = PartialWithNulls<{
|
|
|
40
40
|
declare const filterValues: (pageTargets: Record<string, unknown>) => Record<string, string | string[]>;
|
|
41
41
|
type UserId = {
|
|
42
42
|
name: string;
|
|
43
|
-
params?: Record<string, string | number
|
|
43
|
+
params?: Record<string, string | number | boolean | Record<string, unknown>>;
|
|
44
44
|
storage?: {
|
|
45
45
|
type: 'cookie' | 'html5';
|
|
46
46
|
name: string;
|
package/dist/esm/types.d.ts
CHANGED
|
@@ -1,41 +1,6 @@
|
|
|
1
1
|
import type { EventPayload } from '@guardian/ophan-tracker-js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { EventTimer } from './event-timer.js';
|
|
3
3
|
import type { PageTargeting } from './targeting/build-page-targeting.js';
|
|
4
|
-
import '@types/google-publisher-tag';
|
|
5
|
-
type HeaderBiddingSize = AdSize;
|
|
6
|
-
interface Advert {
|
|
7
|
-
id: string;
|
|
8
|
-
node: HTMLElement;
|
|
9
|
-
sizes: SizeMapping;
|
|
10
|
-
headerBiddingSizes: HeaderBiddingSize[] | null;
|
|
11
|
-
size: AdSize | 'fluid' | null;
|
|
12
|
-
slot: googletag.Slot;
|
|
13
|
-
gpid: string | undefined;
|
|
14
|
-
isEmpty: boolean | null;
|
|
15
|
-
isRendered: boolean;
|
|
16
|
-
shouldRefresh: boolean;
|
|
17
|
-
whenSlotReady: Promise<void>;
|
|
18
|
-
extraNodeClasses: string[];
|
|
19
|
-
hasPrebidSize: boolean;
|
|
20
|
-
headerBiddingBidRequest: Promise<unknown> | null;
|
|
21
|
-
lineItemId: number | null;
|
|
22
|
-
creativeId: number | null;
|
|
23
|
-
creativeTemplateId: number | null;
|
|
24
|
-
testgroup: string | undefined;
|
|
25
|
-
finishedRendering(isRendered: boolean): void;
|
|
26
|
-
updateExtraSlotClasses(...newClasses: string[]): Promise<void>;
|
|
27
|
-
generateSizeMapping(additionalSizeMapping: SizeMapping): SizeMapping;
|
|
28
|
-
updateSizeMapping(additionalSizeMapping: SizeMapping): void;
|
|
29
|
-
}
|
|
30
|
-
interface DfpEnv {
|
|
31
|
-
renderStartTime: number;
|
|
32
|
-
adSlotSelector: string;
|
|
33
|
-
lazyLoadEnabled: boolean;
|
|
34
|
-
lazyLoadObserve: boolean;
|
|
35
|
-
advertsToLoad: Advert[];
|
|
36
|
-
adverts: Map<Advert['id'], Advert>;
|
|
37
|
-
shouldLazyLoad: () => boolean;
|
|
38
|
-
}
|
|
39
4
|
type ConnectionType = 'bluetooth' | 'cellular' | 'ethernet' | 'mixed' | 'none' | 'other' | 'unknown' | 'wifi';
|
|
40
5
|
interface NetworkInformation extends EventTarget {
|
|
41
6
|
readonly type?: ConnectionType;
|
|
@@ -430,4 +395,19 @@ type AdmiralEvent = Record<string, unknown>;
|
|
|
430
395
|
type AdmiralCallback = (event: AdmiralEvent) => void;
|
|
431
396
|
type AdmiralArg = string | AdmiralCallback;
|
|
432
397
|
type Admiral = (...args: AdmiralArg[]) => void;
|
|
433
|
-
|
|
398
|
+
interface CoreGuardian {
|
|
399
|
+
config: Config;
|
|
400
|
+
commercialTimer?: EventTimer;
|
|
401
|
+
offlineCount?: number;
|
|
402
|
+
modules: {
|
|
403
|
+
sentry?: {
|
|
404
|
+
reportError?: (error: Error, feature: string, tags?: Record<string, string>, extras?: Record<string, unknown>) => void;
|
|
405
|
+
};
|
|
406
|
+
abTests?: {
|
|
407
|
+
getParticipations: () => Record<string, string>;
|
|
408
|
+
isUserInTest: (testId: string) => boolean;
|
|
409
|
+
isUserInTestGroup: (testId: string, variantId: string) => boolean;
|
|
410
|
+
};
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
export type { ConnectionType, NetworkInformation, OphanRecordFunction, Indices, Edition, AdsConfigDisabled, AdsConfigEnabled, AdsConfigBasic, AdsConfigUSNATorAus, AdsConfigTCFV2, AdsConfig, AdTargetingBuilder, Ophan, Config, AdBlockers, ArticleCounts, FetchBidResponse, HeaderNotification, OptOutInitializeOptions, OptOutAdSlot, Confiant, Permutive, Apstag, ComscoreGlobals, IasPET, TeadsAnalytics, SafeFrameAPI, NSdkInstance, Trac, GoogleTagParams, GoogleTrackConversionObject, Admiral, AdmiralEvent, CoreGuardian, };
|
package/dist/esm/types.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@guardian/commercial-core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "31.0.0",
|
|
4
4
|
"description": "Guardian advertising business logic",
|
|
5
5
|
"homepage": "https://github.com/guardian/commercial#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -33,23 +33,22 @@
|
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"@guardian/ab-core": "^9.0.0",
|
|
36
|
-
"@guardian/libs": "^
|
|
36
|
+
"@guardian/libs": "^30.1.0"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@guardian/ab-core": "9.0.0",
|
|
40
|
-
"@guardian/libs": "
|
|
41
|
-
"@types/google-publisher-tag": "~1.20251117.0"
|
|
40
|
+
"@guardian/libs": "30.1.0"
|
|
42
41
|
},
|
|
43
42
|
"devDependencies": {
|
|
44
|
-
"@guardian/ophan-tracker-js": "2.
|
|
43
|
+
"@guardian/ophan-tracker-js": "2.8.0",
|
|
45
44
|
"@types/jest": "30.0.0",
|
|
46
|
-
"@types/node": "
|
|
45
|
+
"@types/node": "25.2.0",
|
|
47
46
|
"jest": "^30.2.0",
|
|
48
47
|
"jest-environment-jsdom": "^30.2.0",
|
|
49
48
|
"jest-environment-jsdom-global": "~4.0.0",
|
|
50
49
|
"ts-jest": "^29.4.6",
|
|
51
50
|
"tsc-alias": "1.8.16",
|
|
52
|
-
"type-fest": "^4.
|
|
51
|
+
"type-fest": "^5.4.3",
|
|
53
52
|
"typescript": "5.9.3"
|
|
54
53
|
},
|
|
55
54
|
"publishConfig": {
|