@guardian/commercial-core 29.1.0 → 29.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/cjs/email-hash.d.ts +1 -0
- package/dist/cjs/email-hash.js +16 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +3 -1
- package/dist/cjs/targeting/teads-eligibility.js +3 -4
- package/dist/esm/email-hash.d.ts +1 -0
- package/dist/esm/email-hash.js +13 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/targeting/teads-eligibility.js +3 -4
- package/package.json +7 -6
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function hashEmail(email: string): Promise<string>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hashEmail = hashEmail;
|
|
4
|
+
async function sha256(string) {
|
|
5
|
+
const utf8 = new TextEncoder().encode(string);
|
|
6
|
+
const hashBuffer = await crypto.subtle.digest('SHA-256', utf8);
|
|
7
|
+
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
8
|
+
const hashHex = hashArray
|
|
9
|
+
.map((bytes) => bytes.toString(16).padStart(2, '0'))
|
|
10
|
+
.join('');
|
|
11
|
+
return hashHex;
|
|
12
|
+
}
|
|
13
|
+
function hashEmail(email) {
|
|
14
|
+
const normalisedEmail = email.trim().toLowerCase();
|
|
15
|
+
return sha256(normalisedEmail);
|
|
16
|
+
}
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export { postMessage } from './messenger/post-message';
|
|
|
8
8
|
export { buildImaAdTagUrl } from './targeting/youtube-ima';
|
|
9
9
|
export { getPermutivePFPSegments } from './permutive';
|
|
10
10
|
export { isEligibleForTeads } from './targeting/teads-eligibility';
|
|
11
|
+
export { hashEmail } from './email-hash';
|
|
11
12
|
export type { AdSize, SizeMapping, SlotName } from './ad-sizes';
|
|
12
13
|
export type { PageTargeting } from './targeting/build-page-targeting';
|
|
13
14
|
export type { AdsConfigDisabled, AdsConfigUSNATorAus, AdsConfigTCFV2, } from './types';
|
package/dist/cjs/index.js
CHANGED
|
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.isEligibleForTeads = exports.getPermutivePFPSegments = exports.buildImaAdTagUrl = exports.buildPageTargeting = exports.initCommercialMetrics = exports.bypassCommercialMetricsSampling = exports.constants = exports.adSizes = exports.EventTimer = exports.isAdBlockInUse = void 0;
|
|
36
|
+
exports.hashEmail = exports.isEligibleForTeads = exports.getPermutivePFPSegments = exports.buildImaAdTagUrl = exports.buildPageTargeting = exports.initCommercialMetrics = exports.bypassCommercialMetricsSampling = exports.constants = exports.adSizes = exports.EventTimer = exports.isAdBlockInUse = void 0;
|
|
37
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
39
|
var event_timer_1 = require("./event-timer");
|
|
@@ -54,3 +54,5 @@ var permutive_1 = require("./permutive");
|
|
|
54
54
|
Object.defineProperty(exports, "getPermutivePFPSegments", { enumerable: true, get: function () { return permutive_1.getPermutivePFPSegments; } });
|
|
55
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");
|
|
58
|
+
Object.defineProperty(exports, "hashEmail", { enumerable: true, get: function () { return email_hash_1.hashEmail; } });
|
|
@@ -5,10 +5,9 @@ const allowedContentTypes = ['Article', 'LiveBlog'];
|
|
|
5
5
|
const isEligibleForTeads = (slotId) => {
|
|
6
6
|
const { contentType, isSensitive } = window.guardian.config.page;
|
|
7
7
|
// This IAS value is returned when a page is thought to contain content which is not brand safe
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
.includes('IAS_16425_KW');
|
|
8
|
+
const iasKw = window.googletag.getConfig('targeting').targeting?.['ias-kw'];
|
|
9
|
+
const iasKwArray = Array.isArray(iasKw) ? iasKw : iasKw ? [iasKw] : [];
|
|
10
|
+
const isBrandSafe = !iasKwArray.includes('IAS_16425_KW');
|
|
12
11
|
if (slotId === 'dfp-ad--inline1' &&
|
|
13
12
|
allowedContentTypes.includes(contentType) &&
|
|
14
13
|
!isSensitive &&
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function hashEmail(email: string): Promise<string>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
async function sha256(string) {
|
|
2
|
+
const utf8 = new TextEncoder().encode(string);
|
|
3
|
+
const hashBuffer = await crypto.subtle.digest('SHA-256', utf8);
|
|
4
|
+
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
5
|
+
const hashHex = hashArray
|
|
6
|
+
.map((bytes) => bytes.toString(16).padStart(2, '0'))
|
|
7
|
+
.join('');
|
|
8
|
+
return hashHex;
|
|
9
|
+
}
|
|
10
|
+
export function hashEmail(email) {
|
|
11
|
+
const normalisedEmail = email.trim().toLowerCase();
|
|
12
|
+
return sha256(normalisedEmail);
|
|
13
|
+
}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export { postMessage } from './messenger/post-message';
|
|
|
8
8
|
export { buildImaAdTagUrl } from './targeting/youtube-ima';
|
|
9
9
|
export { getPermutivePFPSegments } from './permutive';
|
|
10
10
|
export { isEligibleForTeads } from './targeting/teads-eligibility';
|
|
11
|
+
export { hashEmail } from './email-hash';
|
|
11
12
|
export type { AdSize, SizeMapping, SlotName } from './ad-sizes';
|
|
12
13
|
export type { PageTargeting } from './targeting/build-page-targeting';
|
|
13
14
|
export type { AdsConfigDisabled, AdsConfigUSNATorAus, AdsConfigTCFV2, } from './types';
|
package/dist/esm/index.js
CHANGED
|
@@ -8,3 +8,4 @@ export { postMessage } from './messenger/post-message';
|
|
|
8
8
|
export { buildImaAdTagUrl } from './targeting/youtube-ima';
|
|
9
9
|
export { getPermutivePFPSegments } from './permutive';
|
|
10
10
|
export { isEligibleForTeads } from './targeting/teads-eligibility';
|
|
11
|
+
export { hashEmail } from './email-hash';
|
|
@@ -2,10 +2,9 @@ const allowedContentTypes = ['Article', 'LiveBlog'];
|
|
|
2
2
|
const isEligibleForTeads = (slotId) => {
|
|
3
3
|
const { contentType, isSensitive } = window.guardian.config.page;
|
|
4
4
|
// This IAS value is returned when a page is thought to contain content which is not brand safe
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
.includes('IAS_16425_KW');
|
|
5
|
+
const iasKw = window.googletag.getConfig('targeting').targeting?.['ias-kw'];
|
|
6
|
+
const iasKwArray = Array.isArray(iasKw) ? iasKw : iasKw ? [iasKw] : [];
|
|
7
|
+
const isBrandSafe = !iasKwArray.includes('IAS_16425_KW');
|
|
9
8
|
if (slotId === 'dfp-ad--inline1' &&
|
|
10
9
|
allowedContentTypes.includes(contentType) &&
|
|
11
10
|
!isSensitive &&
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@guardian/commercial-core",
|
|
3
|
-
"version": "29.
|
|
3
|
+
"version": "29.3.0",
|
|
4
4
|
"description": "Guardian advertising business logic",
|
|
5
5
|
"homepage": "https://github.com/guardian/commercial#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
},
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
|
-
"url": "git+https://github.com/guardian/commercial.git"
|
|
11
|
+
"url": "git+https://github.com/guardian/commercial.git",
|
|
12
|
+
"directory": "core"
|
|
12
13
|
},
|
|
13
14
|
"license": "Apache-2.0",
|
|
14
15
|
"files": [
|
|
@@ -35,19 +36,19 @@
|
|
|
35
36
|
},
|
|
36
37
|
"dependencies": {
|
|
37
38
|
"@guardian/ab-core": "8.0.1",
|
|
38
|
-
"@guardian/libs": "26.0.
|
|
39
|
-
"@types/googletag": "~3.3.0"
|
|
39
|
+
"@guardian/libs": "26.0.1"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@guardian/ophan-tracker-js": "2.6.1",
|
|
43
43
|
"@types/jest": "30.0.0",
|
|
44
44
|
"@types/node": "24.7.2",
|
|
45
|
+
"@types/google-publisher-tag": "~1.20250811.1",
|
|
45
46
|
"jest": "^30.2.0",
|
|
46
47
|
"jest-environment-jsdom": "^30.2.0",
|
|
47
48
|
"jest-environment-jsdom-global": "~4.0.0",
|
|
48
49
|
"ts-jest": "^29.4.4",
|
|
49
|
-
"
|
|
50
|
-
"
|
|
50
|
+
"type-fest": "^4.41.0",
|
|
51
|
+
"typescript": "5.9.3"
|
|
51
52
|
},
|
|
52
53
|
"publishConfig": {
|
|
53
54
|
"access": "public"
|