@pubtech-ai/core 1.6.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/LICENSE +202 -0
- package/README.md +527 -0
- package/lib/cjs/Cloneable.d.ts +27 -0
- package/lib/cjs/Cloneable.js +1 -0
- package/lib/cjs/GVL.d.ts +295 -0
- package/lib/cjs/GVL.js +1 -0
- package/lib/cjs/Json.d.ts +20 -0
- package/lib/cjs/Json.js +1 -0
- package/lib/cjs/TCModel.d.ts +337 -0
- package/lib/cjs/TCModel.js +1 -0
- package/lib/cjs/TCString.d.ts +27 -0
- package/lib/cjs/TCString.js +1 -0
- package/lib/cjs/encoder/Base64Url.d.ts +29 -0
- package/lib/cjs/encoder/Base64Url.js +1 -0
- package/lib/cjs/encoder/BitLength.d.ts +32 -0
- package/lib/cjs/encoder/BitLength.js +1 -0
- package/lib/cjs/encoder/EncodingOptions.d.ts +6 -0
- package/lib/cjs/encoder/EncodingOptions.js +1 -0
- package/lib/cjs/encoder/SegmentEncoder.d.ts +8 -0
- package/lib/cjs/encoder/SegmentEncoder.js +1 -0
- package/lib/cjs/encoder/SemanticPreEncoder.d.ts +6 -0
- package/lib/cjs/encoder/SemanticPreEncoder.js +1 -0
- package/lib/cjs/encoder/field/BooleanEncoder.d.ts +4 -0
- package/lib/cjs/encoder/field/BooleanEncoder.js +1 -0
- package/lib/cjs/encoder/field/DateEncoder.d.ts +4 -0
- package/lib/cjs/encoder/field/DateEncoder.js +1 -0
- package/lib/cjs/encoder/field/FieldEncoderMap.d.ts +1 -0
- package/lib/cjs/encoder/field/FieldEncoderMap.js +1 -0
- package/lib/cjs/encoder/field/FixedVectorEncoder.d.ts +5 -0
- package/lib/cjs/encoder/field/FixedVectorEncoder.js +1 -0
- package/lib/cjs/encoder/field/IntEncoder.d.ts +4 -0
- package/lib/cjs/encoder/field/IntEncoder.js +1 -0
- package/lib/cjs/encoder/field/LangEncoder.d.ts +4 -0
- package/lib/cjs/encoder/field/LangEncoder.js +1 -0
- package/lib/cjs/encoder/field/PurposeRestrictionVectorEncoder.d.ts +5 -0
- package/lib/cjs/encoder/field/PurposeRestrictionVectorEncoder.js +1 -0
- package/lib/cjs/encoder/field/VectorEncodingType.d.ts +4 -0
- package/lib/cjs/encoder/field/VectorEncodingType.js +1 -0
- package/lib/cjs/encoder/field/VendorVectorEncoder.d.ts +6 -0
- package/lib/cjs/encoder/field/VendorVectorEncoder.js +1 -0
- package/lib/cjs/encoder/field/index.d.ts +9 -0
- package/lib/cjs/encoder/field/index.js +1 -0
- package/lib/cjs/encoder/index.d.ts +7 -0
- package/lib/cjs/encoder/index.js +1 -0
- package/lib/cjs/encoder/sequence/FieldSequence.d.ts +5 -0
- package/lib/cjs/encoder/sequence/FieldSequence.js +1 -0
- package/lib/cjs/encoder/sequence/SegmentSequence.d.ts +9 -0
- package/lib/cjs/encoder/sequence/SegmentSequence.js +1 -0
- package/lib/cjs/encoder/sequence/SequenceVersionMap.d.ts +7 -0
- package/lib/cjs/encoder/sequence/SequenceVersionMap.js +1 -0
- package/lib/cjs/encoder/sequence/index.d.ts +3 -0
- package/lib/cjs/encoder/sequence/index.js +1 -0
- package/lib/cjs/errors/DecodingError.d.ts +15 -0
- package/lib/cjs/errors/DecodingError.js +1 -0
- package/lib/cjs/errors/EncodingError.d.ts +15 -0
- package/lib/cjs/errors/EncodingError.js +1 -0
- package/lib/cjs/errors/GVLError.d.ts +15 -0
- package/lib/cjs/errors/GVLError.js +1 -0
- package/lib/cjs/errors/TCModelError.d.ts +16 -0
- package/lib/cjs/errors/TCModelError.js +1 -0
- package/lib/cjs/errors/index.d.ts +4 -0
- package/lib/cjs/errors/index.js +1 -0
- package/lib/cjs/index.d.ts +8 -0
- package/lib/cjs/index.js +1 -0
- package/lib/cjs/model/BinarySearchTree.d.ts +30 -0
- package/lib/cjs/model/BinarySearchTree.js +1 -0
- package/lib/cjs/model/ConsentLanguages.d.ts +6 -0
- package/lib/cjs/model/ConsentLanguages.js +1 -0
- package/lib/cjs/model/DeviceDisclosure.d.ts +9 -0
- package/lib/cjs/model/DeviceDisclosure.js +1 -0
- package/lib/cjs/model/DeviceDisclosureStorageAccessType.d.ts +5 -0
- package/lib/cjs/model/DeviceDisclosureStorageAccessType.js +1 -0
- package/lib/cjs/model/Fields.d.ts +29 -0
- package/lib/cjs/model/Fields.js +1 -0
- package/lib/cjs/model/IntMap.d.ts +13 -0
- package/lib/cjs/model/IntMap.js +1 -0
- package/lib/cjs/model/KeyMap.d.ts +12 -0
- package/lib/cjs/model/KeyMap.js +1 -0
- package/lib/cjs/model/PurposeRestriction.d.ts +33 -0
- package/lib/cjs/model/PurposeRestriction.js +1 -0
- package/lib/cjs/model/PurposeRestrictionVector.d.ts +100 -0
- package/lib/cjs/model/PurposeRestrictionVector.js +1 -0
- package/lib/cjs/model/RestrictionType.d.ts +19 -0
- package/lib/cjs/model/RestrictionType.js +1 -0
- package/lib/cjs/model/Segment.d.ts +6 -0
- package/lib/cjs/model/Segment.js +1 -0
- package/lib/cjs/model/SegmentIDs.d.ts +12 -0
- package/lib/cjs/model/SegmentIDs.js +1 -0
- package/lib/cjs/model/Vector.d.ts +72 -0
- package/lib/cjs/model/Vector.js +1 -0
- package/lib/cjs/model/gvl/ByPurposeVendorMap.d.ts +7 -0
- package/lib/cjs/model/gvl/ByPurposeVendorMap.js +1 -0
- package/lib/cjs/model/gvl/DataCategory.d.ts +4 -0
- package/lib/cjs/model/gvl/DataCategory.js +1 -0
- package/lib/cjs/model/gvl/DataRetention.d.ts +6 -0
- package/lib/cjs/model/gvl/DataRetention.js +1 -0
- package/lib/cjs/model/gvl/Declarations.d.ts +13 -0
- package/lib/cjs/model/gvl/Declarations.js +1 -0
- package/lib/cjs/model/gvl/Feature.d.ts +5 -0
- package/lib/cjs/model/gvl/Feature.js +1 -0
- package/lib/cjs/model/gvl/GVLMapItem.d.ts +4 -0
- package/lib/cjs/model/gvl/GVLMapItem.js +1 -0
- package/lib/cjs/model/gvl/IDSetMap.d.ts +2 -0
- package/lib/cjs/model/gvl/IDSetMap.js +1 -0
- package/lib/cjs/model/gvl/Purpose.d.ts +5 -0
- package/lib/cjs/model/gvl/Purpose.js +1 -0
- package/lib/cjs/model/gvl/Stack.d.ts +6 -0
- package/lib/cjs/model/gvl/Stack.js +1 -0
- package/lib/cjs/model/gvl/Vendor.d.ts +24 -0
- package/lib/cjs/model/gvl/Vendor.js +1 -0
- package/lib/cjs/model/gvl/VendorList.d.ts +10 -0
- package/lib/cjs/model/gvl/VendorList.js +1 -0
- package/lib/cjs/model/gvl/VendorUrl.d.ts +5 -0
- package/lib/cjs/model/gvl/VendorUrl.js +1 -0
- package/lib/cjs/model/gvl/index.d.ts +10 -0
- package/lib/cjs/model/gvl/index.js +1 -0
- package/lib/cjs/model/index.d.ts +14 -0
- package/lib/cjs/model/index.js +1 -0
- package/lib/cjs/package.json +3 -0
- package/lib/mjs/Cloneable.d.ts +27 -0
- package/lib/mjs/Cloneable.js +76 -0
- package/lib/mjs/GVL.d.ts +295 -0
- package/lib/mjs/GVL.js +591 -0
- package/lib/mjs/Json.d.ts +20 -0
- package/lib/mjs/Json.js +74 -0
- package/lib/mjs/TCModel.d.ts +337 -0
- package/lib/mjs/TCModel.js +512 -0
- package/lib/mjs/TCString.d.ts +27 -0
- package/lib/mjs/TCString.js +71 -0
- package/lib/mjs/encoder/Base64Url.d.ts +29 -0
- package/lib/mjs/encoder/Base64Url.js +80 -0
- package/lib/mjs/encoder/BitLength.d.ts +32 -0
- package/lib/mjs/encoder/BitLength.js +32 -0
- package/lib/mjs/encoder/EncodingOptions.d.ts +6 -0
- package/lib/mjs/encoder/EncodingOptions.js +1 -0
- package/lib/mjs/encoder/SegmentEncoder.d.ts +8 -0
- package/lib/mjs/encoder/SegmentEncoder.js +106 -0
- package/lib/mjs/encoder/SemanticPreEncoder.d.ts +6 -0
- package/lib/mjs/encoder/SemanticPreEncoder.js +133 -0
- package/lib/mjs/encoder/field/BooleanEncoder.d.ts +4 -0
- package/lib/mjs/encoder/field/BooleanEncoder.js +9 -0
- package/lib/mjs/encoder/field/DateEncoder.d.ts +4 -0
- package/lib/mjs/encoder/field/DateEncoder.js +15 -0
- package/lib/mjs/encoder/field/FieldEncoderMap.d.ts +1 -0
- package/lib/mjs/encoder/field/FieldEncoderMap.js +39 -0
- package/lib/mjs/encoder/field/FixedVectorEncoder.d.ts +5 -0
- package/lib/mjs/encoder/field/FixedVectorEncoder.js +25 -0
- package/lib/mjs/encoder/field/IntEncoder.d.ts +4 -0
- package/lib/mjs/encoder/field/IntEncoder.js +25 -0
- package/lib/mjs/encoder/field/LangEncoder.d.ts +4 -0
- package/lib/mjs/encoder/field/LangEncoder.js +36 -0
- package/lib/mjs/encoder/field/PurposeRestrictionVectorEncoder.d.ts +5 -0
- package/lib/mjs/encoder/field/PurposeRestrictionVectorEncoder.js +109 -0
- package/lib/mjs/encoder/field/VectorEncodingType.d.ts +4 -0
- package/lib/mjs/encoder/field/VectorEncodingType.js +5 -0
- package/lib/mjs/encoder/field/VendorVectorEncoder.d.ts +6 -0
- package/lib/mjs/encoder/field/VendorVectorEncoder.js +156 -0
- package/lib/mjs/encoder/field/index.d.ts +9 -0
- package/lib/mjs/encoder/field/index.js +9 -0
- package/lib/mjs/encoder/index.d.ts +7 -0
- package/lib/mjs/encoder/index.js +7 -0
- package/lib/mjs/encoder/sequence/FieldSequence.d.ts +5 -0
- package/lib/mjs/encoder/sequence/FieldSequence.js +53 -0
- package/lib/mjs/encoder/sequence/SegmentSequence.d.ts +9 -0
- package/lib/mjs/encoder/sequence/SegmentSequence.js +52 -0
- package/lib/mjs/encoder/sequence/SequenceVersionMap.d.ts +7 -0
- package/lib/mjs/encoder/sequence/SequenceVersionMap.js +1 -0
- package/lib/mjs/encoder/sequence/index.d.ts +3 -0
- package/lib/mjs/encoder/sequence/index.js +4 -0
- package/lib/mjs/errors/DecodingError.d.ts +15 -0
- package/lib/mjs/errors/DecodingError.js +18 -0
- package/lib/mjs/errors/EncodingError.d.ts +15 -0
- package/lib/mjs/errors/EncodingError.js +18 -0
- package/lib/mjs/errors/GVLError.d.ts +15 -0
- package/lib/mjs/errors/GVLError.js +18 -0
- package/lib/mjs/errors/TCModelError.d.ts +16 -0
- package/lib/mjs/errors/TCModelError.js +19 -0
- package/lib/mjs/errors/index.d.ts +4 -0
- package/lib/mjs/errors/index.js +4 -0
- package/lib/mjs/index.d.ts +8 -0
- package/lib/mjs/index.js +9 -0
- package/lib/mjs/model/BinarySearchTree.d.ts +30 -0
- package/lib/mjs/model/BinarySearchTree.js +267 -0
- package/lib/mjs/model/ConsentLanguages.d.ts +6 -0
- package/lib/mjs/model/ConsentLanguages.js +42 -0
- package/lib/mjs/model/DeviceDisclosure.d.ts +9 -0
- package/lib/mjs/model/DeviceDisclosure.js +1 -0
- package/lib/mjs/model/DeviceDisclosureStorageAccessType.d.ts +5 -0
- package/lib/mjs/model/DeviceDisclosureStorageAccessType.js +6 -0
- package/lib/mjs/model/Fields.d.ts +29 -0
- package/lib/mjs/model/Fields.js +29 -0
- package/lib/mjs/model/IntMap.d.ts +13 -0
- package/lib/mjs/model/IntMap.js +1 -0
- package/lib/mjs/model/KeyMap.d.ts +12 -0
- package/lib/mjs/model/KeyMap.js +1 -0
- package/lib/mjs/model/PurposeRestriction.d.ts +33 -0
- package/lib/mjs/model/PurposeRestriction.js +69 -0
- package/lib/mjs/model/PurposeRestrictionVector.d.ts +100 -0
- package/lib/mjs/model/PurposeRestrictionVector.js +286 -0
- package/lib/mjs/model/RestrictionType.d.ts +19 -0
- package/lib/mjs/model/RestrictionType.js +20 -0
- package/lib/mjs/model/Segment.d.ts +6 -0
- package/lib/mjs/model/Segment.js +7 -0
- package/lib/mjs/model/SegmentIDs.d.ts +12 -0
- package/lib/mjs/model/SegmentIDs.js +21 -0
- package/lib/mjs/model/Vector.d.ts +72 -0
- package/lib/mjs/model/Vector.js +161 -0
- package/lib/mjs/model/gvl/ByPurposeVendorMap.d.ts +7 -0
- package/lib/mjs/model/gvl/ByPurposeVendorMap.js +1 -0
- package/lib/mjs/model/gvl/DataCategory.d.ts +4 -0
- package/lib/mjs/model/gvl/DataCategory.js +1 -0
- package/lib/mjs/model/gvl/DataRetention.d.ts +6 -0
- package/lib/mjs/model/gvl/DataRetention.js +1 -0
- package/lib/mjs/model/gvl/Declarations.d.ts +13 -0
- package/lib/mjs/model/gvl/Declarations.js +1 -0
- package/lib/mjs/model/gvl/Feature.d.ts +5 -0
- package/lib/mjs/model/gvl/Feature.js +2 -0
- package/lib/mjs/model/gvl/GVLMapItem.d.ts +4 -0
- package/lib/mjs/model/gvl/GVLMapItem.js +1 -0
- package/lib/mjs/model/gvl/IDSetMap.d.ts +2 -0
- package/lib/mjs/model/gvl/IDSetMap.js +1 -0
- package/lib/mjs/model/gvl/Purpose.d.ts +5 -0
- package/lib/mjs/model/gvl/Purpose.js +1 -0
- package/lib/mjs/model/gvl/Stack.d.ts +6 -0
- package/lib/mjs/model/gvl/Stack.js +1 -0
- package/lib/mjs/model/gvl/Vendor.d.ts +24 -0
- package/lib/mjs/model/gvl/Vendor.js +1 -0
- package/lib/mjs/model/gvl/VendorList.d.ts +10 -0
- package/lib/mjs/model/gvl/VendorList.js +1 -0
- package/lib/mjs/model/gvl/VendorUrl.d.ts +5 -0
- package/lib/mjs/model/gvl/VendorUrl.js +1 -0
- package/lib/mjs/model/gvl/index.d.ts +10 -0
- package/lib/mjs/model/gvl/index.js +11 -0
- package/lib/mjs/model/index.d.ts +14 -0
- package/lib/mjs/model/index.js +14 -0
- package/lib/mjs/package.json +3 -0
- package/package.json +95 -0
|
@@ -0,0 +1,512 @@
|
|
|
1
|
+
import { Cloneable } from './Cloneable.js';
|
|
2
|
+
import { TCModelError } from './errors/index.js';
|
|
3
|
+
import { GVL } from './GVL.js';
|
|
4
|
+
import { PurposeRestrictionVector, Vector } from './model/index.js';
|
|
5
|
+
export class TCModel extends Cloneable {
|
|
6
|
+
/**
|
|
7
|
+
* Set of available consent languages published by the IAB
|
|
8
|
+
*/
|
|
9
|
+
static consentLanguages = GVL.consentLanguages;
|
|
10
|
+
isServiceSpecific_ = false;
|
|
11
|
+
supportOOB_ = true;
|
|
12
|
+
useNonStandardStacks_ = false;
|
|
13
|
+
purposeOneTreatment_ = false;
|
|
14
|
+
publisherCountryCode_ = 'AA';
|
|
15
|
+
version_ = 2;
|
|
16
|
+
consentScreen_ = 0;
|
|
17
|
+
policyVersion_ = 4;
|
|
18
|
+
consentLanguage_ = 'EN';
|
|
19
|
+
cmpId_ = 0;
|
|
20
|
+
cmpVersion_ = 0;
|
|
21
|
+
vendorListVersion_ = 0;
|
|
22
|
+
numCustomPurposes_ = 0;
|
|
23
|
+
// Member Variable for GVL
|
|
24
|
+
gvl_;
|
|
25
|
+
created;
|
|
26
|
+
lastUpdated;
|
|
27
|
+
/**
|
|
28
|
+
* The TCF designates certain Features as special, that is, a CMP must afford
|
|
29
|
+
* the user a means to opt in to their use. These Special Features are
|
|
30
|
+
* published and numbered in the GVL separately from normal Features.
|
|
31
|
+
* Provides for up to 12 special features.
|
|
32
|
+
*/
|
|
33
|
+
specialFeatureOptins = new Vector();
|
|
34
|
+
/**
|
|
35
|
+
* Renamed from `PurposesAllowed` in TCF v1.1
|
|
36
|
+
* The user’s consent value for each Purpose established on the legal basis
|
|
37
|
+
* of consent. Purposes are published in the Global Vendor List (see. [[GVL]]).
|
|
38
|
+
*/
|
|
39
|
+
purposeConsents = new Vector();
|
|
40
|
+
/**
|
|
41
|
+
* The user’s permission for each Purpose established on the legal basis of
|
|
42
|
+
* legitimate interest. If the user has exercised right-to-object for a
|
|
43
|
+
* purpose.
|
|
44
|
+
*/
|
|
45
|
+
purposeLegitimateInterests = new Vector();
|
|
46
|
+
/**
|
|
47
|
+
* The user’s consent value for each Purpose established on the legal basis
|
|
48
|
+
* of consent, for the publisher. Purposes are published in the Global
|
|
49
|
+
* Vendor List.
|
|
50
|
+
*/
|
|
51
|
+
publisherConsents = new Vector();
|
|
52
|
+
/**
|
|
53
|
+
* The user’s permission for each Purpose established on the legal basis of
|
|
54
|
+
* legitimate interest. If the user has exercised right-to-object for a
|
|
55
|
+
* purpose.
|
|
56
|
+
*/
|
|
57
|
+
publisherLegitimateInterests = new Vector();
|
|
58
|
+
/**
|
|
59
|
+
* The user’s consent value for each Purpose established on the legal basis
|
|
60
|
+
* of consent, for the publisher. Purposes are published in the Global
|
|
61
|
+
* Vendor List.
|
|
62
|
+
*/
|
|
63
|
+
publisherCustomConsents = new Vector();
|
|
64
|
+
/**
|
|
65
|
+
* The user’s permission for each Purpose established on the legal basis of
|
|
66
|
+
* legitimate interest. If the user has exercised right-to-object for a
|
|
67
|
+
* purpose that is established in the publisher's custom purposes.
|
|
68
|
+
*/
|
|
69
|
+
publisherCustomLegitimateInterests = new Vector();
|
|
70
|
+
/**
|
|
71
|
+
* set by a publisher if they wish to collect consent and LI Transparency for
|
|
72
|
+
* purposes outside of the TCF
|
|
73
|
+
*/
|
|
74
|
+
customPurposes;
|
|
75
|
+
/**
|
|
76
|
+
* Each [[Vendor]] is keyed by id. Their consent value is true if it is in
|
|
77
|
+
* the Vector
|
|
78
|
+
*/
|
|
79
|
+
vendorConsents = new Vector();
|
|
80
|
+
/**
|
|
81
|
+
* Each [[Vendor]] is keyed by id. Whether their Legitimate Interests
|
|
82
|
+
* Disclosures have been established is stored as boolean.
|
|
83
|
+
* see: [[Vector]]
|
|
84
|
+
*/
|
|
85
|
+
vendorLegitimateInterests = new Vector();
|
|
86
|
+
/**
|
|
87
|
+
* The value included for disclosed vendors signals which vendors have been
|
|
88
|
+
* disclosed to the user in the interface surfaced by the CMP. This section
|
|
89
|
+
* content is required when writing a TC string to the global (consensu)
|
|
90
|
+
* scope. When a CMP has read from and is updating a TC string from the
|
|
91
|
+
* global consensu.org storage, the CMP MUST retain the existing disclosure
|
|
92
|
+
* information and only add information for vendors that it has disclosed
|
|
93
|
+
* that had not been disclosed by other CMPs in prior interactions with this
|
|
94
|
+
* device/user agent.
|
|
95
|
+
*/
|
|
96
|
+
vendorsDisclosed = new Vector();
|
|
97
|
+
/**
|
|
98
|
+
* Signals which vendors the publisher permits to use OOB legal bases.
|
|
99
|
+
*/
|
|
100
|
+
vendorsAllowed = new Vector();
|
|
101
|
+
publisherRestrictions = new PurposeRestrictionVector();
|
|
102
|
+
/**
|
|
103
|
+
* Constructs the TCModel. Passing a [[GVL]] is optional when constructing
|
|
104
|
+
* as this TCModel may be constructed from decoding an existing encoded
|
|
105
|
+
* TCString.
|
|
106
|
+
*
|
|
107
|
+
* @param {GVL} [gvl]
|
|
108
|
+
*/
|
|
109
|
+
constructor(gvl) {
|
|
110
|
+
super();
|
|
111
|
+
if (gvl) {
|
|
112
|
+
this.gvl = gvl;
|
|
113
|
+
}
|
|
114
|
+
this.updated();
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* sets the [[GVL]] with side effects of also setting the `vendorListVersion`, `policyVersion`, and `consentLanguage`
|
|
118
|
+
* @param {GVL} gvl
|
|
119
|
+
*/
|
|
120
|
+
set gvl(gvl) {
|
|
121
|
+
/**
|
|
122
|
+
* set the reference, but make sure it's our GVL wrapper class.
|
|
123
|
+
*/
|
|
124
|
+
if (!(GVL.isInstanceOf(gvl))) {
|
|
125
|
+
gvl = new GVL(gvl);
|
|
126
|
+
}
|
|
127
|
+
this.gvl_ = gvl;
|
|
128
|
+
this.publisherRestrictions.gvl = gvl;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* @return {GVL} the gvl instance set on this TCModel instance
|
|
132
|
+
*/
|
|
133
|
+
get gvl() {
|
|
134
|
+
return this.gvl_;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* @param {number} integer - A unique ID will be assigned to each Consent
|
|
138
|
+
* Manager Provider (CMP) from the iab.
|
|
139
|
+
*
|
|
140
|
+
* @throws {TCModelError} if the value is not an integer greater than 1 as those are not valid.
|
|
141
|
+
*/
|
|
142
|
+
set cmpId(integer) {
|
|
143
|
+
integer = Number(integer);
|
|
144
|
+
if (Number.isInteger(integer) && integer > 1) {
|
|
145
|
+
this.cmpId_ = integer;
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
throw new TCModelError('cmpId', integer);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
get cmpId() {
|
|
152
|
+
return this.cmpId_;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Each change to an operating CMP should receive a
|
|
156
|
+
* new version number, for logging proof of consent. CmpVersion defined by
|
|
157
|
+
* each CMP.
|
|
158
|
+
*
|
|
159
|
+
* @param {number} integer
|
|
160
|
+
*
|
|
161
|
+
* @throws {TCModelError} if the value is not an integer greater than 1 as those are not valid.
|
|
162
|
+
*/
|
|
163
|
+
set cmpVersion(integer) {
|
|
164
|
+
integer = Number(integer);
|
|
165
|
+
if (Number.isInteger(integer) && integer > -1) {
|
|
166
|
+
this.cmpVersion_ = integer;
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
throw new TCModelError('cmpVersion', integer);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
get cmpVersion() {
|
|
173
|
+
return this.cmpVersion_;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* The screen number is CMP and CmpVersion
|
|
177
|
+
* specific, and is for logging proof of consent.(For example, a CMP could
|
|
178
|
+
* keep records so that a publisher can request information about the context
|
|
179
|
+
* in which consent was gathered.)
|
|
180
|
+
*
|
|
181
|
+
* @param {number} integer
|
|
182
|
+
*
|
|
183
|
+
* @throws {TCModelError} if the value is not an integer greater than 0 as those are not valid.
|
|
184
|
+
*/
|
|
185
|
+
set consentScreen(integer) {
|
|
186
|
+
integer = Number(integer);
|
|
187
|
+
if (Number.isInteger(integer) && integer > -1) {
|
|
188
|
+
this.consentScreen_ = integer;
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
throw new TCModelError('consentScreen', integer);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
get consentScreen() {
|
|
195
|
+
return this.consentScreen_;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* @param {string} lang - [two-letter ISO 639-1 language
|
|
199
|
+
* code](http://www.loc.gov/standards/iso639-2/php/code_list.php) in which
|
|
200
|
+
* the CMP UI was presented
|
|
201
|
+
*
|
|
202
|
+
* @throws {TCModelError} if the value is not a length-2 string of alpha characters
|
|
203
|
+
*/
|
|
204
|
+
set consentLanguage(lang) {
|
|
205
|
+
this.consentLanguage_ = lang;
|
|
206
|
+
}
|
|
207
|
+
get consentLanguage() {
|
|
208
|
+
return this.consentLanguage_;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* @param {string} countryCode - [two-letter ISO 3166-1 alpha-2 country
|
|
212
|
+
* code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the publisher,
|
|
213
|
+
* determined by the CMP-settings of the publisher.
|
|
214
|
+
*
|
|
215
|
+
* @throws {TCModelError} if the value is not a length-2 string of alpha characters
|
|
216
|
+
*/
|
|
217
|
+
set publisherCountryCode(countryCode) {
|
|
218
|
+
if (/^([A-z]){2}$/.test(countryCode)) {
|
|
219
|
+
this.publisherCountryCode_ = countryCode.toUpperCase();
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
throw new TCModelError('publisherCountryCode', countryCode);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
get publisherCountryCode() {
|
|
226
|
+
return this.publisherCountryCode_;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Version of the GVL used to create this TCModel. Global
|
|
230
|
+
* Vendor List versions will be released periodically.
|
|
231
|
+
*
|
|
232
|
+
* @param {number} integer
|
|
233
|
+
*
|
|
234
|
+
* @throws {TCModelError} if the value is not an integer greater than 0 as those are not valid.
|
|
235
|
+
*/
|
|
236
|
+
set vendorListVersion(integer) {
|
|
237
|
+
/**
|
|
238
|
+
* first coerce to a number via leading '+' then take the integer value by
|
|
239
|
+
* bitshifting to the right. This works on all types in JavaScript and if
|
|
240
|
+
* it's not valid then value will be 0.
|
|
241
|
+
*/
|
|
242
|
+
integer = Number(integer) >> 0;
|
|
243
|
+
if (integer < 0) {
|
|
244
|
+
throw new TCModelError('vendorListVersion', integer);
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
247
|
+
this.vendorListVersion_ = integer;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
get vendorListVersion() {
|
|
251
|
+
if (this.gvl) {
|
|
252
|
+
return this.gvl.vendorListVersion;
|
|
253
|
+
}
|
|
254
|
+
else {
|
|
255
|
+
return this.vendorListVersion_;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* From the corresponding field in the GVL that was
|
|
260
|
+
* used for obtaining consent. A new policy version invalidates existing
|
|
261
|
+
* strings and requires CMPs to re-establish transparency and consent from
|
|
262
|
+
* users.
|
|
263
|
+
*
|
|
264
|
+
* If a TCF policy version number is different from the one from the latest
|
|
265
|
+
* GVL, the CMP must re-establish transparency and consent.
|
|
266
|
+
*
|
|
267
|
+
* @param {number} num - You do not need to set this. This comes
|
|
268
|
+
* directly from the [[GVL]].
|
|
269
|
+
*
|
|
270
|
+
*/
|
|
271
|
+
set policyVersion(num) {
|
|
272
|
+
this.policyVersion_ = parseInt(num, 10);
|
|
273
|
+
if (this.policyVersion_ < 0) {
|
|
274
|
+
throw new TCModelError('policyVersion', num);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
get policyVersion() {
|
|
278
|
+
if (this.gvl) {
|
|
279
|
+
return this.gvl.tcfPolicyVersion;
|
|
280
|
+
}
|
|
281
|
+
else {
|
|
282
|
+
return this.policyVersion_;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
set version(num) {
|
|
286
|
+
this.version_ = parseInt(num, 10);
|
|
287
|
+
}
|
|
288
|
+
get version() {
|
|
289
|
+
return this.version_;
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Whether the signals encoded in this TC String were from site-specific
|
|
293
|
+
* storage `true` versus ‘global’ consensu.org shared storage `false`. A
|
|
294
|
+
* string intended to be stored in global/shared scope but the CMP is unable
|
|
295
|
+
* to store due to a user agent not accepting third-party cookies would be
|
|
296
|
+
* considered site-specific `true`.
|
|
297
|
+
*
|
|
298
|
+
* @param {boolean} bool - value to set. Some changes to other fields in this
|
|
299
|
+
* model will automatically change this value like adding publisher
|
|
300
|
+
* restrictions.
|
|
301
|
+
*/
|
|
302
|
+
set isServiceSpecific(bool) {
|
|
303
|
+
this.isServiceSpecific_ = bool;
|
|
304
|
+
}
|
|
305
|
+
get isServiceSpecific() {
|
|
306
|
+
return this.isServiceSpecific_;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Non-standard stacks means that a CMP is using publisher-customized stack
|
|
310
|
+
* descriptions. Stacks (in terms of purposes in a stack) are pre-set by the
|
|
311
|
+
* IAB. As are titles. Descriptions are pre-set, but publishers can customize
|
|
312
|
+
* them. If they do, they need to set this bit to indicate that they've
|
|
313
|
+
* customized descriptions.
|
|
314
|
+
*
|
|
315
|
+
* @param {boolean} bool - value to set
|
|
316
|
+
*/
|
|
317
|
+
set useNonStandardStacks(bool) {
|
|
318
|
+
this.useNonStandardStacks_ = bool;
|
|
319
|
+
}
|
|
320
|
+
get useNonStandardStacks() {
|
|
321
|
+
return this.useNonStandardStacks_;
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Whether or not this publisher supports OOB signaling. On Global TC String
|
|
325
|
+
* OOB Vendors Disclosed will be included if the publish wishes to no allow
|
|
326
|
+
* these vendors they should set this to false.
|
|
327
|
+
* @param {boolean} bool - value to set
|
|
328
|
+
*/
|
|
329
|
+
set supportOOB(bool) {
|
|
330
|
+
this.supportOOB_ = bool;
|
|
331
|
+
}
|
|
332
|
+
get supportOOB() {
|
|
333
|
+
return this.supportOOB_;
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* `false` There is no special Purpose 1 status.
|
|
337
|
+
* Purpose 1 was disclosed normally (consent) as expected by Policy. `true`
|
|
338
|
+
* Purpose 1 not disclosed at all. CMPs use PublisherCC to indicate the
|
|
339
|
+
* publisher’s country of establishment to help Vendors determine whether the
|
|
340
|
+
* vendor requires Purpose 1 consent. In global scope TC strings, this field
|
|
341
|
+
* must always have a value of `false`. When a CMP encounters a global scope
|
|
342
|
+
* string with `purposeOneTreatment=true` then that string should be
|
|
343
|
+
* considered invalid and the CMP must re-establish transparency and consent.
|
|
344
|
+
*
|
|
345
|
+
* @param {boolean} bool
|
|
346
|
+
*/
|
|
347
|
+
set purposeOneTreatment(bool) {
|
|
348
|
+
this.purposeOneTreatment_ = bool;
|
|
349
|
+
}
|
|
350
|
+
get purposeOneTreatment() {
|
|
351
|
+
return this.purposeOneTreatment_;
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* setAllVendorConsents - sets all vendors on the GVL Consent (true)
|
|
355
|
+
*
|
|
356
|
+
* @return {void}
|
|
357
|
+
*/
|
|
358
|
+
setAllVendorConsents() {
|
|
359
|
+
this.vendorConsents.set(this.gvl.vendors);
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* unsetAllVendorConsents - unsets all vendors on the GVL Consent (false)
|
|
363
|
+
*
|
|
364
|
+
* @return {void}
|
|
365
|
+
*/
|
|
366
|
+
unsetAllVendorConsents() {
|
|
367
|
+
this.vendorConsents.empty();
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* setAllVendorsDisclosed - sets all vendors on the GVL Vendors Disclosed (true)
|
|
371
|
+
*
|
|
372
|
+
* @return {void}
|
|
373
|
+
*/
|
|
374
|
+
setAllVendorsDisclosed() {
|
|
375
|
+
this.vendorsDisclosed.set(this.gvl.vendors);
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* unsetAllVendorsDisclosed - unsets all vendors on the GVL Consent (false)
|
|
379
|
+
*
|
|
380
|
+
* @return {void}
|
|
381
|
+
*/
|
|
382
|
+
unsetAllVendorsDisclosed() {
|
|
383
|
+
this.vendorsDisclosed.empty();
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* setAllVendorsAllowed - sets all vendors on the GVL Consent (true)
|
|
387
|
+
*
|
|
388
|
+
* @return {void}
|
|
389
|
+
*/
|
|
390
|
+
setAllVendorsAllowed() {
|
|
391
|
+
this.vendorsAllowed.set(this.gvl.vendors);
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* unsetAllVendorsAllowed - unsets all vendors on the GVL Consent (false)
|
|
395
|
+
*
|
|
396
|
+
* @return {void}
|
|
397
|
+
*/
|
|
398
|
+
unsetAllVendorsAllowed() {
|
|
399
|
+
this.vendorsAllowed.empty();
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* setAllVendorLegitimateInterests - sets all vendors on the GVL LegitimateInterests (true)
|
|
403
|
+
*
|
|
404
|
+
* @return {void}
|
|
405
|
+
*/
|
|
406
|
+
setAllVendorLegitimateInterests() {
|
|
407
|
+
this.vendorLegitimateInterests.set(this.gvl.vendors);
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* unsetAllVendorLegitimateInterests - unsets all vendors on the GVL LegitimateInterests (false)
|
|
411
|
+
*
|
|
412
|
+
* @return {void}
|
|
413
|
+
*/
|
|
414
|
+
unsetAllVendorLegitimateInterests() {
|
|
415
|
+
this.vendorLegitimateInterests.empty();
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* setAllPurposeConsents - sets all purposes on the GVL Consent (true)
|
|
419
|
+
*
|
|
420
|
+
* @return {void}
|
|
421
|
+
*/
|
|
422
|
+
setAllPurposeConsents() {
|
|
423
|
+
this.purposeConsents.set(this.gvl.purposes);
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* unsetAllPurposeConsents - unsets all purposes on the GVL Consent (false)
|
|
427
|
+
*
|
|
428
|
+
* @return {void}
|
|
429
|
+
*/
|
|
430
|
+
unsetAllPurposeConsents() {
|
|
431
|
+
this.purposeConsents.empty();
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
* setAllPurposeLegitimateInterests - sets all purposes on the GVL LI Transparency (true)
|
|
435
|
+
*
|
|
436
|
+
* @return {void}
|
|
437
|
+
*/
|
|
438
|
+
setAllPurposeLegitimateInterests() {
|
|
439
|
+
this.purposeLegitimateInterests.set(this.gvl.purposes);
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* unsetAllPurposeLegitimateInterests - unsets all purposes on the GVL LI Transparency (false)
|
|
443
|
+
*
|
|
444
|
+
* @return {void}
|
|
445
|
+
*/
|
|
446
|
+
unsetAllPurposeLegitimateInterests() {
|
|
447
|
+
this.purposeLegitimateInterests.empty();
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* setAllSpecialFeatureOptins - sets all special featuresOptins on the GVL (true)
|
|
451
|
+
*
|
|
452
|
+
* @return {void}
|
|
453
|
+
*/
|
|
454
|
+
setAllSpecialFeatureOptins() {
|
|
455
|
+
this.specialFeatureOptins.set(this.gvl.specialFeatures);
|
|
456
|
+
}
|
|
457
|
+
/**
|
|
458
|
+
* unsetAllSpecialFeatureOptins - unsets all special featuresOptins on the GVL (true)
|
|
459
|
+
*
|
|
460
|
+
* @return {void}
|
|
461
|
+
*/
|
|
462
|
+
unsetAllSpecialFeatureOptins() {
|
|
463
|
+
this.specialFeatureOptins.empty();
|
|
464
|
+
}
|
|
465
|
+
setAll() {
|
|
466
|
+
this.setAllVendorConsents();
|
|
467
|
+
this.setAllPurposeLegitimateInterests();
|
|
468
|
+
this.setAllSpecialFeatureOptins();
|
|
469
|
+
this.setAllPurposeConsents();
|
|
470
|
+
this.setAllVendorLegitimateInterests();
|
|
471
|
+
}
|
|
472
|
+
unsetAll() {
|
|
473
|
+
this.unsetAllVendorConsents();
|
|
474
|
+
this.unsetAllPurposeLegitimateInterests();
|
|
475
|
+
this.unsetAllSpecialFeatureOptins();
|
|
476
|
+
this.unsetAllPurposeConsents();
|
|
477
|
+
this.unsetAllVendorLegitimateInterests();
|
|
478
|
+
}
|
|
479
|
+
get numCustomPurposes() {
|
|
480
|
+
let len = this.numCustomPurposes_;
|
|
481
|
+
if (typeof this.customPurposes === 'object') {
|
|
482
|
+
/**
|
|
483
|
+
* Keys are not guaranteed to be in order and likewise there is no
|
|
484
|
+
* requirement that the customPurposes be non-sparse. So we have to sort
|
|
485
|
+
* and take the highest value. Even if the set only contains 3 purposes
|
|
486
|
+
* but goes to ID 6 we need to set the number to 6 for the encoding to
|
|
487
|
+
* work properly since it's positional.
|
|
488
|
+
*/
|
|
489
|
+
const purposeIds = Object.keys(this.customPurposes)
|
|
490
|
+
.sort((a, b) => Number(a) - Number(b));
|
|
491
|
+
len = parseInt(purposeIds.pop(), 10);
|
|
492
|
+
}
|
|
493
|
+
return len;
|
|
494
|
+
}
|
|
495
|
+
set numCustomPurposes(num) {
|
|
496
|
+
this.numCustomPurposes_ = parseInt(num, 10);
|
|
497
|
+
if (this.numCustomPurposes_ < 0) {
|
|
498
|
+
throw new TCModelError('numCustomPurposes', num);
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
* updated - updates the created and lastUpdated dates with a 'now' day-level UTC timestamp
|
|
503
|
+
*
|
|
504
|
+
* @return {void}
|
|
505
|
+
*/
|
|
506
|
+
updated() {
|
|
507
|
+
const date = new Date();
|
|
508
|
+
const utcDate = new Date(Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate()));
|
|
509
|
+
this.created = utcDate;
|
|
510
|
+
this.lastUpdated = utcDate;
|
|
511
|
+
}
|
|
512
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { EncodingOptions } from './encoder/index.js';
|
|
2
|
+
import { TCModel } from './TCModel.js';
|
|
3
|
+
/**
|
|
4
|
+
* Main class for encoding and decoding a
|
|
5
|
+
* TCF Transparency and Consent String
|
|
6
|
+
*/
|
|
7
|
+
export declare class TCString {
|
|
8
|
+
/**
|
|
9
|
+
* encodes a model into a TCString
|
|
10
|
+
*
|
|
11
|
+
* @param {TCModel} tcModel - model to convert into encoded string
|
|
12
|
+
* @param {EncodingOptions} options - for encoding options other than default
|
|
13
|
+
* @return {string} - base64url encoded Transparency and Consent String
|
|
14
|
+
*/
|
|
15
|
+
static encode(tcModel: TCModel, options?: EncodingOptions): string;
|
|
16
|
+
/**
|
|
17
|
+
* Decodes a string into a TCModel
|
|
18
|
+
*
|
|
19
|
+
* @param {string} encodedTCString - base64url encoded Transparency and
|
|
20
|
+
* Consent String to decode - can also be a single or group of segments of
|
|
21
|
+
* the string
|
|
22
|
+
* @param {string} [tcModel] - model to enhance with the information. If
|
|
23
|
+
* none is passed a new instance of TCModel will be created.
|
|
24
|
+
* @return {TCModel} - Returns populated TCModel
|
|
25
|
+
*/
|
|
26
|
+
static decode(encodedTCString: string, tcModel?: TCModel): TCModel;
|
|
27
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Base64Url, BitLength, SegmentEncoder, SegmentSequence, SemanticPreEncoder, } from './encoder/index.js';
|
|
2
|
+
import { SegmentIDs } from './model/index.js';
|
|
3
|
+
import { IntEncoder } from './encoder/field/IntEncoder.js';
|
|
4
|
+
import { TCModel } from './TCModel.js';
|
|
5
|
+
/**
|
|
6
|
+
* Main class for encoding and decoding a
|
|
7
|
+
* TCF Transparency and Consent String
|
|
8
|
+
*/
|
|
9
|
+
export class TCString {
|
|
10
|
+
/**
|
|
11
|
+
* encodes a model into a TCString
|
|
12
|
+
*
|
|
13
|
+
* @param {TCModel} tcModel - model to convert into encoded string
|
|
14
|
+
* @param {EncodingOptions} options - for encoding options other than default
|
|
15
|
+
* @return {string} - base64url encoded Transparency and Consent String
|
|
16
|
+
*/
|
|
17
|
+
static encode(tcModel, options) {
|
|
18
|
+
let out = '';
|
|
19
|
+
let sequence;
|
|
20
|
+
tcModel = SemanticPreEncoder.process(tcModel, options);
|
|
21
|
+
/**
|
|
22
|
+
* If they pass in a special segment sequence.
|
|
23
|
+
*/
|
|
24
|
+
if (Array.isArray(options?.segments)) {
|
|
25
|
+
sequence = options.segments;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
sequence = new SegmentSequence(tcModel, options)['' + tcModel.version];
|
|
29
|
+
}
|
|
30
|
+
sequence.forEach((segment, idx) => {
|
|
31
|
+
let dotMaybe = '';
|
|
32
|
+
if (idx < sequence.length - 1) {
|
|
33
|
+
dotMaybe = '.';
|
|
34
|
+
}
|
|
35
|
+
out += SegmentEncoder.encode(tcModel, segment) + dotMaybe;
|
|
36
|
+
});
|
|
37
|
+
return out;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Decodes a string into a TCModel
|
|
41
|
+
*
|
|
42
|
+
* @param {string} encodedTCString - base64url encoded Transparency and
|
|
43
|
+
* Consent String to decode - can also be a single or group of segments of
|
|
44
|
+
* the string
|
|
45
|
+
* @param {string} [tcModel] - model to enhance with the information. If
|
|
46
|
+
* none is passed a new instance of TCModel will be created.
|
|
47
|
+
* @return {TCModel} - Returns populated TCModel
|
|
48
|
+
*/
|
|
49
|
+
static decode(encodedTCString, tcModel) {
|
|
50
|
+
const segments = encodedTCString.split('.');
|
|
51
|
+
const len = segments.length;
|
|
52
|
+
if (!tcModel) {
|
|
53
|
+
tcModel = new TCModel();
|
|
54
|
+
}
|
|
55
|
+
for (let i = 0; i < len; i++) {
|
|
56
|
+
const segString = segments[i];
|
|
57
|
+
/**
|
|
58
|
+
* first char will contain 6 bits, we only need the first 3. In version 1
|
|
59
|
+
* and 2 of the TC string there is no segment type for the CORE string.
|
|
60
|
+
* Instead the first 6 bits are reserved for the encoding version, but
|
|
61
|
+
* because we're only on a maximum of encoding version 2 the first 3 bits
|
|
62
|
+
* in the core segment will evaluate to 0.
|
|
63
|
+
*/
|
|
64
|
+
const firstChar = Base64Url.decode(segString.charAt(0));
|
|
65
|
+
const segTypeBits = firstChar.substr(0, BitLength.segmentType);
|
|
66
|
+
const segment = SegmentIDs.ID_TO_KEY[IntEncoder.decode(segTypeBits, BitLength.segmentType).toString()];
|
|
67
|
+
SegmentEncoder.decode(segString, tcModel, segment);
|
|
68
|
+
}
|
|
69
|
+
return tcModel;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export declare class Base64Url {
|
|
2
|
+
/**
|
|
3
|
+
* Base 64 URL character set. Different from standard Base64 char set
|
|
4
|
+
* in that '+' and '/' are replaced with '-' and '_'.
|
|
5
|
+
*/
|
|
6
|
+
private static DICT;
|
|
7
|
+
private static REVERSE_DICT;
|
|
8
|
+
/**
|
|
9
|
+
* log2(64) = 6
|
|
10
|
+
*/
|
|
11
|
+
private static BASIS;
|
|
12
|
+
private static LCM;
|
|
13
|
+
/**
|
|
14
|
+
* encodes an arbitrary-length bitfield string into base64url
|
|
15
|
+
*
|
|
16
|
+
* @static
|
|
17
|
+
* @param {string} str - arbitrary-length bitfield string to be encoded to base64url
|
|
18
|
+
* @return {string} - base64url encoded result
|
|
19
|
+
*/
|
|
20
|
+
static encode(str: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* decodes a base64url encoded bitfield string
|
|
23
|
+
*
|
|
24
|
+
* @static
|
|
25
|
+
* @param {string} str - base64url encoded bitfield string to be decoded
|
|
26
|
+
* @return {string} - bitfield string
|
|
27
|
+
*/
|
|
28
|
+
static decode(str: string): string;
|
|
29
|
+
}
|