@active-reach/web-sdk 1.3.1 → 1.4.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/aegis.min.js +1 -1
- package/dist/aegis.min.js.map +1 -1
- package/dist/{analytics-B0JfoAJs.mjs → analytics-D9BAnJAu.mjs} +264 -2
- package/dist/analytics-D9BAnJAu.mjs.map +1 -0
- package/dist/cdn.d.ts +7 -0
- package/dist/cdn.d.ts.map +1 -1
- package/dist/core/analytics.d.ts +20 -0
- package/dist/core/analytics.d.ts.map +1 -1
- package/dist/core/bootstrap.d.ts +71 -0
- package/dist/core/bootstrap.d.ts.map +1 -0
- package/dist/governance/bloom-filter.d.ts +47 -0
- package/dist/governance/bloom-filter.d.ts.map +1 -0
- package/dist/governance/index.d.ts +6 -0
- package/dist/governance/index.d.ts.map +1 -0
- package/dist/governance/murmur3.d.ts +43 -0
- package/dist/governance/murmur3.d.ts.map +1 -0
- package/dist/governance/name-governor.d.ts +88 -0
- package/dist/governance/name-governor.d.ts.map +1 -0
- package/dist/inapp/AegisInAppManager.d.ts +2 -0
- package/dist/inapp/AegisInAppManager.d.ts.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +94 -9
- package/dist/index.js.map +1 -1
- package/dist/push/AegisWebPush.d.ts +17 -2
- package/dist/push/AegisWebPush.d.ts.map +1 -1
- package/dist/push/AegisWebPush.js +95 -29
- package/dist/push/AegisWebPush.js.map +1 -1
- package/dist/react.js +1 -1
- package/package.json +1 -1
- package/dist/analytics-B0JfoAJs.mjs.map +0 -1
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MurmurHash3 x86-32 — deterministic, byte-identical with Python `mmh3.hash`.
|
|
3
|
+
*
|
|
4
|
+
* We hand-roll rather than pull a dep because (a) our bundle-budget is
|
|
5
|
+
* aggressive for storefront first-paint, and (b) this is the authoritative
|
|
6
|
+
* cross-language hash for the event-governance bloom filter — any behavior
|
|
7
|
+
* drift between Python and JS produces silent FP-rate spikes in prod.
|
|
8
|
+
*
|
|
9
|
+
* Contract:
|
|
10
|
+
* • Input is a JS string. It is UTF-8 encoded via TextEncoder before hashing.
|
|
11
|
+
* • Output is an unsigned 32-bit integer (0 .. 2^32-1).
|
|
12
|
+
* • Matches `mmh3.hash(s.encode('utf-8'), seed=seed, signed=False)` in
|
|
13
|
+
* Python exactly — verified by libs/shared-types/bloom-test-vectors.json
|
|
14
|
+
* in CI.
|
|
15
|
+
*
|
|
16
|
+
* Reference: Austin Appleby, MurmurHash3 (public domain).
|
|
17
|
+
* https://github.com/aappleby/smhasher/blob/master/src/MurmurHash3.cpp
|
|
18
|
+
*
|
|
19
|
+
* Implementation notes:
|
|
20
|
+
* • All arithmetic on 32-bit ints. JS does bitwise ops on 32-bit ints natively;
|
|
21
|
+
* `Math.imul` gives us correct 32-bit multiplication without overflow.
|
|
22
|
+
* • We use `>>> 0` to coerce to unsigned after every step that could produce
|
|
23
|
+
* a negative or >32-bit value.
|
|
24
|
+
* • UTF-8 encoding matters — a naive `charCodeAt` loop would mis-hash any
|
|
25
|
+
* string with non-ASCII characters (e.g. emoji, accented chars) and the
|
|
26
|
+
* Python side would disagree. We always encode via TextEncoder first.
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* Compute MurmurHash3 x86-32 of a UTF-8 encoded string.
|
|
30
|
+
*
|
|
31
|
+
* @param input The string to hash.
|
|
32
|
+
* @param seed 32-bit unsigned seed.
|
|
33
|
+
* @returns Unsigned 32-bit integer hash.
|
|
34
|
+
*/
|
|
35
|
+
export declare function murmurhash3_x86_32(input: string, seed?: number): number;
|
|
36
|
+
/**
|
|
37
|
+
* Compute MurmurHash3 x86-32 over a byte buffer directly.
|
|
38
|
+
*
|
|
39
|
+
* Exposed for callers that already have UTF-8 bytes and want to skip the
|
|
40
|
+
* encode step (e.g., internal bloom-hash paths).
|
|
41
|
+
*/
|
|
42
|
+
export declare function murmurhash3_bytes(bytes: Uint8Array, seed?: number): number;
|
|
43
|
+
//# sourceMappingURL=murmur3.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"murmur3.d.ts","sourceRoot":"","sources":["../../src/governance/murmur3.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAKH;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,GAAE,MAAU,GAAG,MAAM,CAI1E;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,GAAE,MAAU,GAAG,MAAM,CA+C7E"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NameGovernor — client-side event-name cap enforcement.
|
|
3
|
+
*
|
|
4
|
+
* The governor consumes an `EventGovernanceHint` from the bootstrap response
|
|
5
|
+
* and decides whether to let a `track()` call proceed to the network or drop
|
|
6
|
+
* it locally.
|
|
7
|
+
*
|
|
8
|
+
* Why this exists:
|
|
9
|
+
* Without it, a page that calls `track('new_btn_' + Date.now())` in a
|
|
10
|
+
* render loop would (a) pass the local rate-limiter if within burst, (b)
|
|
11
|
+
* force the gateway to ask control-plane for a verdict on every unique
|
|
12
|
+
* name, and (c) amplify the CP `/event-governance/check` load quadratically
|
|
13
|
+
* in the number of tabs firing the same bug. The bloom filter gives the
|
|
14
|
+
* SDK enough information to drop novel names locally once the org hits
|
|
15
|
+
* its cap, collapsing the amplification to zero.
|
|
16
|
+
*
|
|
17
|
+
* Design constraints:
|
|
18
|
+
* • FAIL-OPEN — missing hint (Enterprise org, Redis outage) lets every
|
|
19
|
+
* name through. The gateway is still the authoritative cap.
|
|
20
|
+
* • FALSE-POSITIVE-SAFE — if the bloom says "known" for a name that isn't
|
|
21
|
+
* actually registered, we send to gateway and the gateway's exact check
|
|
22
|
+
* catches it. FPs cost one round trip, not a cap bypass.
|
|
23
|
+
* • LOCAL-MEMO — a novel name that has already charged `remainingNewNames`
|
|
24
|
+
* in this tab must NOT charge again on subsequent calls within the same
|
|
25
|
+
* hint TTL. Without this, `track('new_btn_click')` fired 50 times would
|
|
26
|
+
* drain 50 from the counter and block every OTHER legitimate novel name.
|
|
27
|
+
* See `localNovelNames`.
|
|
28
|
+
*
|
|
29
|
+
* See docs/architecture/RFC_2026_04_SDK_GOVERNANCE_HINTS.md §3.3.
|
|
30
|
+
*/
|
|
31
|
+
/** Shape of the hint delivered by `/v1/sdk/bootstrap`. */
|
|
32
|
+
export interface EventGovernanceHint {
|
|
33
|
+
bloom_algo: string;
|
|
34
|
+
seed_a: number;
|
|
35
|
+
seed_b: number;
|
|
36
|
+
k: number;
|
|
37
|
+
m: number;
|
|
38
|
+
bloom_b64: string;
|
|
39
|
+
remaining_new_names: number | null;
|
|
40
|
+
ttl_seconds: number;
|
|
41
|
+
}
|
|
42
|
+
export interface DropReport {
|
|
43
|
+
/** Map of event_name → count of local drops since last drain. */
|
|
44
|
+
events: Record<string, number>;
|
|
45
|
+
/** Total events dropped across all names (sum of values). */
|
|
46
|
+
total: number;
|
|
47
|
+
/** When the report window started (ms since epoch). */
|
|
48
|
+
since: number;
|
|
49
|
+
}
|
|
50
|
+
export declare class NameGovernor {
|
|
51
|
+
private bloom;
|
|
52
|
+
private remainingNewNames;
|
|
53
|
+
/**
|
|
54
|
+
* Names this SDK instance has seen AS NOVEL and already charged against
|
|
55
|
+
* `remainingNewNames`. Reset on every `ingestHint()` so we don't leak
|
|
56
|
+
* accounting across hint refreshes.
|
|
57
|
+
*/
|
|
58
|
+
private localNovelNames;
|
|
59
|
+
/** Coalesced telemetry — flushed to the transport via drainDropReport(). */
|
|
60
|
+
private droppedSinceLastReport;
|
|
61
|
+
private reportWindowStart;
|
|
62
|
+
private hasWarnedThisSession;
|
|
63
|
+
/**
|
|
64
|
+
* Ingest a freshly-bootstrapped hint. Call on every successful bootstrap.
|
|
65
|
+
* Passing `null` disables governance (fail-open).
|
|
66
|
+
*/
|
|
67
|
+
ingestHint(hint: EventGovernanceHint | null): void;
|
|
68
|
+
/**
|
|
69
|
+
* Decide whether a `track()` call should proceed.
|
|
70
|
+
*
|
|
71
|
+
* Returns true = send to network (rate-limiter still runs after).
|
|
72
|
+
* Returns false = drop locally; caller should return early.
|
|
73
|
+
*/
|
|
74
|
+
shouldSend(eventName: string): boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Snapshot + reset the dropped-names counter. Called by the telemetry
|
|
77
|
+
* beacon on batch flush so the gateway gets visibility into client-side
|
|
78
|
+
* drops for ops dashboards.
|
|
79
|
+
*/
|
|
80
|
+
drainDropReport(): DropReport | null;
|
|
81
|
+
/** @internal */
|
|
82
|
+
_debugState(): {
|
|
83
|
+
hasBloom: boolean;
|
|
84
|
+
remaining: number;
|
|
85
|
+
localNovel: number;
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=name-governor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"name-governor.d.ts","sourceRoot":"","sources":["../../src/governance/name-governor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAIH,0DAA0D;AAC1D,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,SAAS,EAAE,MAAM,CAAC;IAClB,mBAAmB,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,UAAU;IACzB,iEAAiE;IACjE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,6DAA6D;IAC7D,KAAK,EAAE,MAAM,CAAC;IACd,uDAAuD;IACvD,KAAK,EAAE,MAAM,CAAC;CACf;AAeD,qBAAa,YAAY;IACvB,OAAO,CAAC,KAAK,CAA4B;IACzC,OAAO,CAAC,iBAAiB,CAAoB;IAE7C;;;;OAIG;IACH,OAAO,CAAC,eAAe,CAA0B;IAEjD,4EAA4E;IAC5E,OAAO,CAAC,sBAAsB,CAAkC;IAChE,OAAO,CAAC,iBAAiB,CAAsB;IAC/C,OAAO,CAAC,oBAAoB,CAAS;IAErC;;;OAGG;IACH,UAAU,CAAC,IAAI,EAAE,mBAAmB,GAAG,IAAI,GAAG,IAAI;IA0BlD;;;;;OAKG;IACH,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;IAiCtC;;;;OAIG;IACH,eAAe,IAAI,UAAU,GAAG,IAAI;IAkBpC,gBAAgB;IAChB,WAAW,IAAI;QAAE,QAAQ,EAAE,OAAO,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE;CAO5E"}
|
|
@@ -51,6 +51,7 @@ export interface AegisInAppConfig {
|
|
|
51
51
|
userId?: string;
|
|
52
52
|
contactId?: string;
|
|
53
53
|
organizationId?: string;
|
|
54
|
+
propertyId?: string;
|
|
54
55
|
debugMode?: boolean;
|
|
55
56
|
enableSSE?: boolean;
|
|
56
57
|
}
|
|
@@ -60,6 +61,7 @@ export declare class AegisInAppManager {
|
|
|
60
61
|
private userId?;
|
|
61
62
|
private contactId?;
|
|
62
63
|
private organizationId?;
|
|
64
|
+
private propertyId?;
|
|
63
65
|
private debugMode;
|
|
64
66
|
private enableSSE;
|
|
65
67
|
private campaigns;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AegisInAppManager.d.ts","sourceRoot":"","sources":["../../src/inapp/AegisInAppManager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,OAAO,GAAG,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AkHnB,OAAO,CAAC,gBAAgB;IA6GxB,OAAO,CAAC,sBAAsB;IAyH9B,OAAO,CAAC,WAAW;IAwGnB,OAAO,CAAC,SAAS;IAiHjB,OAAO,CAAC,YAAY;IASpB,OAAO,CAAC,WAAW;IASnB,OAAO,CAAC,aAAa;IA8IrB,OAAO,CAAC,kBAAkB;IAqC1B,OAAO,CAAC,WAAW;IAgBnB,OAAO,CAAC,aAAa;IAqBrB;;;;;;;;;;;OAWG;YACW,UAAU;IA2CxB,OAAO,CAAC,GAAG;IAMX,OAAO,CAAC,OAAO,CAAC,EAAE;QAAE,YAAY,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI;CA2BpD"}
|
package/dist/index.d.ts
CHANGED
|
@@ -20,8 +20,12 @@ export { SdkConfigPoller } from './core/sdk-config-poller';
|
|
|
20
20
|
export type { SdkConfig, SdkConfigPollerOptions, ConfigChangeCallback } from './core/sdk-config-poller';
|
|
21
21
|
export { AegisWebPush } from './push/AegisWebPush';
|
|
22
22
|
export type { AegisWebPushConfig, AegisAPIClient, ContactIdentity, PushEventTracker, } from './push/AegisWebPush';
|
|
23
|
+
export { bootstrap, readFirstPartyCookie, writeFirstPartyCookie, deriveDeviceFingerprint, BootstrapError, } from './core/bootstrap';
|
|
24
|
+
export type { BootstrapRequest, BootstrapResult } from './core/bootstrap';
|
|
23
25
|
export { RateLimiter } from './core/rate-limiter';
|
|
24
26
|
export type { RateLimiterOptions } from './core/rate-limiter';
|
|
27
|
+
export { NameGovernor, BloomFilter, murmurhash3_x86_32 } from './governance';
|
|
28
|
+
export type { EventGovernanceHint, DropReport, BloomFilterParams } from './governance';
|
|
25
29
|
export { EcommerceTracker } from './ecommerce';
|
|
26
30
|
export type { EcommerceProduct, EcommerceCart, EcommerceCheckout, EcommerceOrder, EcommerceCoupon, EcommerceSearch, EcommerceProductList, EcommerceWishlist, EcommercePromotion, } from './ecommerce';
|
|
27
31
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.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AAc,EACd,eAAe,EACf,eAAe,EACf,oBAAoB,EACpB,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,aAAa,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { l as logger, A as Aegis } from "./analytics-
|
|
2
|
-
import { E, R } from "./analytics-
|
|
1
|
+
import { l as logger, A as Aegis } from "./analytics-D9BAnJAu.mjs";
|
|
2
|
+
import { B, E, N, R, m } from "./analytics-D9BAnJAu.mjs";
|
|
3
3
|
import { AegisWebPush } from "./push/AegisWebPush.js";
|
|
4
4
|
function debounce(func, wait) {
|
|
5
5
|
let timeoutId = null;
|
|
@@ -37,6 +37,7 @@ class AegisInAppManager {
|
|
|
37
37
|
this.userId = config.userId;
|
|
38
38
|
this.contactId = config.contactId;
|
|
39
39
|
this.organizationId = config.organizationId;
|
|
40
|
+
this.propertyId = config.propertyId;
|
|
40
41
|
this.debugMode = config.debugMode || false;
|
|
41
42
|
this.enableSSE = config.enableSSE === true;
|
|
42
43
|
}
|
|
@@ -154,6 +155,9 @@ class AegisInAppManager {
|
|
|
154
155
|
if (this.organizationId) {
|
|
155
156
|
headers["X-Organization-ID"] = this.organizationId;
|
|
156
157
|
}
|
|
158
|
+
if (this.propertyId) {
|
|
159
|
+
headers["X-Property-Id"] = this.propertyId;
|
|
160
|
+
}
|
|
157
161
|
const abAssignments = this.getABAssignments();
|
|
158
162
|
if (Object.keys(abAssignments).length > 0) {
|
|
159
163
|
headers["X-AB-Assignments"] = btoa(JSON.stringify(abAssignments));
|
|
@@ -379,12 +383,12 @@ class AegisInAppManager {
|
|
|
379
383
|
const update = () => {
|
|
380
384
|
const diff = Math.max(0, target - Date.now());
|
|
381
385
|
const h = String(Math.floor(diff / 36e5)).padStart(2, "0");
|
|
382
|
-
const
|
|
386
|
+
const m2 = String(Math.floor(diff % 36e5 / 6e4)).padStart(2, "0");
|
|
383
387
|
const s = String(Math.floor(diff % 6e4 / 1e3)).padStart(2, "0");
|
|
384
388
|
const spans = digits.querySelectorAll("span");
|
|
385
389
|
if (spans.length >= 5) {
|
|
386
390
|
spans[0].textContent = h;
|
|
387
|
-
spans[2].textContent =
|
|
391
|
+
spans[2].textContent = m2;
|
|
388
392
|
spans[4].textContent = s;
|
|
389
393
|
}
|
|
390
394
|
if (diff > 0) requestAnimationFrame(update);
|
|
@@ -1460,11 +1464,11 @@ function renderPreview(config) {
|
|
|
1460
1464
|
debugMode: false,
|
|
1461
1465
|
enableSSE: false
|
|
1462
1466
|
});
|
|
1463
|
-
const
|
|
1464
|
-
|
|
1467
|
+
const m2 = manager;
|
|
1468
|
+
m2.trackEvent = async () => {
|
|
1465
1469
|
};
|
|
1466
|
-
|
|
1467
|
-
|
|
1470
|
+
m2.addAnimationStyles();
|
|
1471
|
+
m2.displayCampaign(config);
|
|
1468
1472
|
}
|
|
1469
1473
|
class AegisPlacementManager {
|
|
1470
1474
|
constructor(config) {
|
|
@@ -4347,6 +4351,79 @@ class SdkConfigPoller {
|
|
|
4347
4351
|
}
|
|
4348
4352
|
}
|
|
4349
4353
|
}
|
|
4354
|
+
const COOKIE_NAME = "aegis_fpc";
|
|
4355
|
+
const COOKIE_MAX_AGE_DAYS = 365 * 2;
|
|
4356
|
+
class BootstrapError extends Error {
|
|
4357
|
+
constructor(status, message) {
|
|
4358
|
+
super(message);
|
|
4359
|
+
this.status = status;
|
|
4360
|
+
this.name = "BootstrapError";
|
|
4361
|
+
}
|
|
4362
|
+
}
|
|
4363
|
+
function readFirstPartyCookie() {
|
|
4364
|
+
if (typeof document === "undefined") return null;
|
|
4365
|
+
const match = document.cookie.match(new RegExp(`(?:^|;\\s*)${COOKIE_NAME}=([^;]+)`));
|
|
4366
|
+
return match ? decodeURIComponent(match[1]) : null;
|
|
4367
|
+
}
|
|
4368
|
+
function writeFirstPartyCookie(cookieId) {
|
|
4369
|
+
if (typeof document === "undefined") return;
|
|
4370
|
+
const expires = /* @__PURE__ */ new Date();
|
|
4371
|
+
expires.setDate(expires.getDate() + COOKIE_MAX_AGE_DAYS);
|
|
4372
|
+
document.cookie = `${COOKIE_NAME}=${encodeURIComponent(cookieId)};expires=${expires.toUTCString()};path=/;SameSite=Lax`;
|
|
4373
|
+
try {
|
|
4374
|
+
window.localStorage.setItem(COOKIE_NAME, cookieId);
|
|
4375
|
+
} catch {
|
|
4376
|
+
}
|
|
4377
|
+
}
|
|
4378
|
+
async function bootstrap(apiHost, req) {
|
|
4379
|
+
const body = { writeKey: req.writeKey };
|
|
4380
|
+
if (req.currentOrigin) body.currentOrigin = req.currentOrigin;
|
|
4381
|
+
if (req.firstPartyCookieId) body.firstPartyCookieId = req.firstPartyCookieId;
|
|
4382
|
+
if (req.attestationToken) body.attestationToken = req.attestationToken;
|
|
4383
|
+
if (req.userAgent) body.userAgent = req.userAgent;
|
|
4384
|
+
const url = `${apiHost.replace(/\/$/, "")}/v1/sdk/bootstrap`;
|
|
4385
|
+
const doFetch = async () => fetch(url, {
|
|
4386
|
+
method: "POST",
|
|
4387
|
+
headers: { "Content-Type": "application/json" },
|
|
4388
|
+
body: JSON.stringify(body),
|
|
4389
|
+
credentials: "omit"
|
|
4390
|
+
});
|
|
4391
|
+
let resp = await doFetch();
|
|
4392
|
+
if (resp.status >= 500) {
|
|
4393
|
+
await new Promise((r) => setTimeout(r, 750));
|
|
4394
|
+
resp = await doFetch();
|
|
4395
|
+
}
|
|
4396
|
+
if (resp.status === 401) {
|
|
4397
|
+
throw new BootstrapError(401, "writeKey not recognized or revoked");
|
|
4398
|
+
}
|
|
4399
|
+
if (resp.status === 403) {
|
|
4400
|
+
throw new BootstrapError(403, "Origin validation failed — this writeKey is bound to a different property");
|
|
4401
|
+
}
|
|
4402
|
+
if (!resp.ok) {
|
|
4403
|
+
throw new BootstrapError(resp.status, `Bootstrap failed: HTTP ${resp.status}`);
|
|
4404
|
+
}
|
|
4405
|
+
const json = await resp.json();
|
|
4406
|
+
writeFirstPartyCookie(json.firstPartyCookieId);
|
|
4407
|
+
return json;
|
|
4408
|
+
}
|
|
4409
|
+
async function deriveDeviceFingerprint(firstPartyCookieId) {
|
|
4410
|
+
const ua = typeof navigator !== "undefined" ? navigator.userAgent : "";
|
|
4411
|
+
const platform = typeof navigator !== "undefined" ? navigator.platform || "" : "";
|
|
4412
|
+
const language = typeof navigator !== "undefined" ? navigator.language || "" : "";
|
|
4413
|
+
const input = `${firstPartyCookieId}|${ua}|${platform}|${language}`;
|
|
4414
|
+
if (typeof crypto !== "undefined" && crypto.subtle) {
|
|
4415
|
+
const bytes = new TextEncoder().encode(input);
|
|
4416
|
+
const hash = await crypto.subtle.digest("SHA-256", bytes);
|
|
4417
|
+
const hex = Array.from(new Uint8Array(hash)).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
4418
|
+
return hex;
|
|
4419
|
+
}
|
|
4420
|
+
let h = 2166136261;
|
|
4421
|
+
for (let i = 0; i < input.length; i++) {
|
|
4422
|
+
h ^= input.charCodeAt(i);
|
|
4423
|
+
h = h + ((h << 1) + (h << 4) + (h << 7) + (h << 8) + (h << 24)) >>> 0;
|
|
4424
|
+
}
|
|
4425
|
+
return `fnv-${h.toString(16)}`;
|
|
4426
|
+
}
|
|
4350
4427
|
const aegis = new Aegis();
|
|
4351
4428
|
export {
|
|
4352
4429
|
Aegis,
|
|
@@ -4354,13 +4431,21 @@ export {
|
|
|
4354
4431
|
AegisPlacementManager,
|
|
4355
4432
|
AegisWebPush,
|
|
4356
4433
|
AegisWidgetManager,
|
|
4434
|
+
B as BloomFilter,
|
|
4435
|
+
BootstrapError,
|
|
4357
4436
|
E as EcommerceTracker,
|
|
4437
|
+
N as NameGovernor,
|
|
4358
4438
|
R as RateLimiter,
|
|
4359
4439
|
SdkConfigPoller,
|
|
4360
4440
|
TriggerEngine,
|
|
4441
|
+
bootstrap,
|
|
4361
4442
|
debounce,
|
|
4362
4443
|
aegis as default,
|
|
4444
|
+
deriveDeviceFingerprint,
|
|
4445
|
+
m as murmurhash3_x86_32,
|
|
4446
|
+
readFirstPartyCookie,
|
|
4363
4447
|
renderPreview,
|
|
4364
|
-
throttle
|
|
4448
|
+
throttle,
|
|
4449
|
+
writeFirstPartyCookie
|
|
4365
4450
|
};
|
|
4366
4451
|
//# sourceMappingURL=index.js.map
|