Repository navigation
Expand file tree
/
Copy pathdefinitions.ts
More file actions
62 lines (50 loc) · 1.93 KB
/
Copy pathdefinitions.ts
File metadata and controls
62 lines (50 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import type { BitField, ConsentState, ConsentStateCode, ConsentType } from "./types";
export const ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_";
export const GCD_LENGTH = 12;
export const CONSENT_STRING_VERSION = "1";
export const CONSENT_TYPES = ["ad_storage", "analytics_storage", "ad_user_data", "ad_personalization"] as const;
export const STRING_POSITIONS = {
version: { position: 0, count: 1 },
ad_storage: { position: 1, count: 2 },
analytics_storage: { position: 3, count: 2 },
ad_user_data: { position: 5, count: 2 },
ad_personalization: { position: 7, count: 2 },
flags: { position: 9, count: 1 },
containerScopedDefaults: { position: 10, count: 1 },
containerScopedUsed: { position: 11, count: 1 },
} as const;
export const STATE_BY_CODE: Readonly<Record<ConsentStateCode, ConsentState | undefined>> = {
0: undefined,
1: undefined,
2: "denied",
3: "granted",
};
export const CONSENT_CODE_BITS = 2;
export const PAIR_OFFSETS = {
implicit: 0,
delegation: 2,
declare: 4,
default: 2,
update: 0,
} as const;
export const DELEGATION_BITS = 4;
export const DELEGATED_TO_OTHER = 8;
export const DELEGATED_TO_KNOWN_TYPE = 12;
export const FLAG_FIELDS: {
active: BitField<1>;
gpc: BitField<1>;
adsSignals: BitField<2>;
usedContainerScopedDefaults: BitField<1>;
} = {
gpc: { position: 9, offset: 3, bits: 1 },
active: { position: 9, offset: 2, bits: 1 },
adsSignals: { position: 9, offset: 0, bits: 2 },
usedContainerScopedDefaults: { position: 11, offset: 2, bits: 1 },
};
export const CONTAINER_SCOPED_DEFAULT_FIELDS: Record<ConsentType, BitField<2>> = {
ad_storage: { position: 10, offset: 4, bits: 2 },
analytics_storage: { position: 10, offset: 2, bits: 2 },
ad_user_data: { position: 10, offset: 0, bits: 2 },
ad_personalization: { position: 11, offset: 0, bits: 2 },
};
export const CONSENT_SOURCE_PRECEDENCE = ["update", "default", "declare", "implicit"] as const;